超时订单管理系统 登录功能

超时订单管理系统 登录功能_第1张图片
1.编写前端页面
2.设置首页


  <welcome-file-list>
    <welcome-file>login.jspwelcome-file>
  welcome-file-list>

3.编写dao层用户登录的接口

public interface UserDao {

    //得到要登录的用户
    public User getLoginUser(Connection connection,String userCode)throws SQLException;
}

注意有关于sql的数据处理要 throws SQLException
4.编写dao接口的实现类

package com.kevin.dao.user;

import com.kevin.dao.BaseDao;
import com.kevin.pojo.User;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @program: sumbs_x
 * @author: 解城文 梧州学院软件开发中心
 * @create: 2021-11-22 17:00
 **/
public class UserDaoImpl implements UserDao {
    public User getLoginUser(Connection connection, String userCode)throws SQLException {

        PreparedStatement pstm = null;
        ResultSet rs = null;
        User user = null;


        if (connection != null) {
            String sql = "select * from smbms_user where userCode=?";
            Object[] params = {userCode};


            rs = BaseDao.execute(connection, pstm, rs, sql, params);
            if (rs.next()) {
                user = new User();
                user.setId(rs.getInt("id"));
                user.setUserCode(rs.getString("userCode"));
                user.setUserName(rs.getString("userName"));
                user.setUserPassword(rs.getString("userPassword"));
                user.setGender(rs.getInt("gender"));
                user.setBirthday(rs.getDate("birthday"));
                user.setPhone(rs.getString("phone"));
                user.setAddress(rs.getString("address"));
                user.setUserRole(rs.getInt("userRole"));
                user.setCreatedBy(rs.getInt("createdBy"));
                user.setCreationDate(rs.getTimestamp("creationDate"));
                user.setModifyBy(rs.getInt("modifyBy"));
                user.setModifyDate(rs.getTimestamp("modifyDate"));
            }
            BaseDao.closeResource(null, pstm, rs);
        }
        return user;
    }
}

5.业务层
超时订单管理系统 登录功能_第2张图片
写中间这个判断是否登录成功

6.业务层实现接口

你可能感兴趣的:(JAVA,WEB,java,maven,java-ee)