为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我用户名匹配不了??

package com.po;


public class Users {

public Users(){

}

private String username;

private int password;

public String getUserName() {

return username;

}

public void setUserName(String username) {

this.username = username;

}

public int getPassword() {

return password;

}

public void setPassword(int password) {

this.password = password;

}

}

<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <base href="<%=basePath%>">

    

    <title>My JSP 'login.jsp' starting page</title>

    

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">    

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->


  </head>

  

  <body>

    <h1>系统登录</h1>

    <hr>

    <form name="loginForm" action="dologin.jsp" method="post">

     <table>

    <tr>

    <td>用户登录:</td>

    <td><input type="text" name="username" value=""/></td>

    </tr>

    <tr>

    <td>密码:</td>

    <td><input type="password" name="password" value=""/></td>

    </tr>

    <tr>

    <td colspan="2" align="center"><input type="submit" value="登录"/></td>

    </tr>

      </table>

    </form>

  </body>

</html>

<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

  <head>

    <base href="<%=basePath%>">

    

    <title>My JSP 'dologin.jsp' starting page</title>

    

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">    

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->


  </head>

  

  <body>

    <h1>登陆成功</h1>

    <h2>setProperty动作元素</h2>

    <hr>

    <jsp:useBean id="myUser" class="com.po.Users" scope="page"/>

    <jsp:setProperty name="myUser" property="*" />

   

        用户名:<%=myUser.getUserName() %>

        密码:<%=myUser.getPassword() %>

  </body>

</html>




正在回答

1 回答

private String username;


public String getUserName() {

return username;

}


你的username的getset的方法写错了,getUserName()应该是setUsername

可以去查查自动生成的方法,就不用自己写,不会错了


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么我用户名匹配不了??

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信