日期:2014-05-18 浏览次数:20652 次
package grapes.action;
import grapes.service.LoginService;
import grapes.util.Util;
import grapes.vo.Login;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.interceptor.validation.SkipValidation;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
/**
* @author Andy
* @date 2013-5-13
*/
public class LoginAction extends ActionSupport {
private int lid ;
private String password ;
private Login login ;
private List<Login> loginList ;
LoginService ls=new LoginService() ;
public String login() {
if(ls.login(login)) {
ActionContext.getContext().getSession().put("username", login.getLusername());
return "LOGIN" ;
}
return "LOGIN" ;
}
public String add() {
login.setLtime(Util.getDateTime());
ls.add(login);
return "LOGIN" ;
}
public String list() {
loginList=ls.list();
return "LOGIN" ;
}
public String delete() {
ls.delById(lid);
return "LOGIN" ;
}
public String update() {
return "LOGIN" ;
}
/**
* getter and setter
*/
public int getLid() {
return lid;
}
public void setLid(int lid) {
this.lid = lid;
}
public Login getLogin() {
return login;
}
public void setLogin(Login login) {
this.login = login;
}
public List<Login> getLoginList() {
return loginList;
}
public void setLoginList(List<Login> loginList) {
this.loginList = loginList;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
<validator type="expression">
<param name="expression">
(password==login.lpassword)
</param>
<message><![CDATA[ confirm must equal to the password ]]></message>
</validator>
<field name="password">
<field-validator type="requiredstring" short-circuit="true">
<message>请确认密码</message>
</field-validator>
</field>
<field name="login">
<field-validator type="visitor">
<param name="appendPr