當我輸入在JSP頁面的用戶名和密碼,該數據就是不能過去到代碼中,我得到了以下錯誤:意外的異常捕獲設置上,錯誤設定表達
意外的異常捕獲設置錯誤設置表達式'password',值爲['123456',]
意外異常捕獲設置類action.login上的'用戶名',錯誤設置表達式'用戶名'與值[''測試',]
的login.jsp:
<body>
<s:form action="login" method="post">
<s:textfield label="username" name="username"/>
<s:password label="password" name="password"/>
<s:submit value="submit"/>
</s:form>
</body>
這是我的動作類: Login.java
public class Login extends ActionSupport implements ModelDriven<User>, Preparable {
/**
* 123
*/
private static final long serialVersionUID = -2484039811971165080L;
private IUserService userService=null;
private String id;
private int pageIndex=1;
private String pageBar;
private List<User> list_t;
private User user;
public void prepare()throws Exception{
System.out.println("--prepare--");
System.out.println(id);
if(id==null||id.length()==0){
user=new User();
}else{
user=getUserService().getUserById(Integer.parseInt(id));
}
}
public String execute()throws Exception{
System.out.println("--execute--");
System.out.println(user.getId());
System.out.println(user.getPassword());
if(getUserService().isLogin(user)){
return SUCCESS;
}
return INPUT;
}
public String save()throws Exception{
if(getUserService().insertUser(user)){
return SUCCESS;
}
return ERROR;
}
public String edit(){
return SUCCESS;
}
public String update()throws Exception{
if(getUserService().updateUser(user)){
return SUCCESS;
}
return ERROR;
}
public String delete()throws Exception{
if(getUserService().deleteUser(Integer.parseInt(id))){
return SUCCESS;
}
return ERROR;
}
public String findAllUser()throws Exception{
try {
System.out.println("findAllUser");
list_t=getUserService().getAllUser();
ServletActionContext.getRequest().setAttribute("list", list_t);
} catch (Exception e) {
}
return SUCCESS;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getPageIndex() {
return pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
}
public String getPageBar() {
return pageBar;
}
public void setPageBar(String pageBar) {
this.pageBar = pageBar;
}
public List<User> getList() {
return list_t;
}
public void setList(List<User> list) {
this.list_t = list;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public void setUserService(IUserService userService) {
this.userService = userService;
}
public IUserService getUserService() {
return userService;
}
public User getModel() {
// TODO Auto-generated method stub
return user;
}
}
你是什麼意思的「數據不能過去的代碼」? – AdamJeffers
該代碼無法獲得我輸入的'用戶名'和'密碼'。 – Wang
除非你知道你在做什麼,否則不要使用modeldriven。 –