Written reference to another project in the registration Action:
/ / struts2
package com.softeem.action;
import com.opensymphony.xwork2.ActionSupport;
import com.softeem.pojo.User;
import com.softeem.service.UserService;
public class RegistAction extends ActionSupport {
private String username;
private String password;
private UserService userservice;
private String tip;
public String getTip () {
return tip;
}
public void setTip (String tip) {
this.tip = tip;
}
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 UserService getUserservice () {
return userservice;
}
public void setUserservice (UserService userservice) {
this.userservice = userservice;
}
public String execute () throws Exception {
if (UserService.saveUser (getUsername (), getPassword ())) {/ / error message here
setTip ("registered successfully");
return "success";
}
else
return "error";
}
}
then they can not go inside saveUser Userservice becomes static, I ask, where is the problem?
------ Solution ---------------------------------------- ----
getUsername (), getPassword ()) write directly to the username and passsword on it
struts servlet package will have set and get methods to get the value you entered
------ For reference only ---------------- -----------------------
instantiate your ah http://blog.csdn.net/ylchou/article/details/7639375
Hey its really helpful Thanks a lot
回复删除