MVC实现用户登录功能登录

MVC实现用户登录功能登录

1.jsp页面

<body>
  <form action="frame_study/frame_loginServlet" method="post">
  <table>
  <tr><td>用户名:</td><td><input type="text" name="loginName" value=""/></td></tr>
    
    <tr><td>密码:</td><td><input type="password" name="loginPwd" value=""/></td></tr>
    <tr><td>验证码:</td><td><input type="text" name="confirmCode" value="">
     <input type="text" id="code" name="code" style="width:300px;height:30px;" value=" .jsp">"/></td></tr>
   
    <tr><td><input type="submit" name="" value="登录"/></td><td><input type="reset"name="" value="重置"/></td></tr>
   </table>
    </form>
  </body>

2.servlet

response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		String loginName=request.getParameter("loginName");
		String loginPwd=request.getParameter("loginPwd");
		frame_loginDao fd=new frame_loginDao();
		if(fd.isTrue(loginName, loginPwd)){
			out.print("登录成功");
		}
		else{
			out.print("用户名或者密码错误");
		}

3.JavaBean


public class frame_loginDao {
	private String userName;
	private String password;
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isTrue(String username,String password){
		if("admin".equals(username)&&"admin".equals(password)){
			return true;
		}
		else{
			return false;	
		}
		
		
	}

你可能感兴趣的:(web前段,web,mvc,jsp)