这是我的动作类,我正确定义了 struts.xml,我的问题是,我得到 textBox 用户名值 NULL,但其他输入正在返回该值。我正在添加 User.java 类,Struts ActionClass。
public class UserLogin extends ActionSupport {
User user = new User();
public String getAccess() {
System.out.println(user.getPassword()+"and"+user.getUserName());
// output: xyz and null
if (user.getPassword().equals("pass")){
System.out.println(user.getUserName());
return "success";
} else{
return "input";
}
}
public User getModel() {
return user;
}
}
我的jsp页面是:
<form action="login">
UserName:<input type="text" name="userName"/>
Password:<input type="password" name="password"/>
<input type="submit" value="login"/>
</form>
用户.java
public User {
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;
}
}