報錯為空指針,應該是沒獲取到值,但是我不知道具體哪裡出了問題..
代碼如下:
User實體
public class User{
private String username;
private String password;
//setter和getter
public User() {
}
public User(String username,String password){
this.username = username;
this.password = password;
}
}
登錄Action
public class LoginAction extends ActionSupport
{
private User user;
public void setUser(User user){
this.user = user;
}
public User getUser(User user){
return this.user;
}
public String execute() throws Exception
{
if (user.getUsername().equals("user") && user.getPassword().equals("123"))
{
return SUCCESS;
}
return ERROR;
}
}
登錄jsp
<s:form action="login">
<s:textfield name="user.username" key="user"/>
<s:textfield name="user.password" key="pass"/>
<s:submit key="login"/>
</s:form>
能不能指教一下具體問題在哪裡,卡著好幾天了,看書調試一直是空指針錯誤
是否在struts配置文件中配置了實體bean