LoginAction
package com.test.action; 2 3 import com.opensymphony.xwork2.ActionContext; 4 import com.opensymphony.xwork2.ActionSupport; 5 6 public class LoginAction extends ActionSupport { 7 private String username; 8 private String password; 9 10 public String getUsername() { 11 return username; 12 } 13 14 public void setUsername(String username) { 15 this.username = username; 16 } 17 18 public String getPassword() { 19 return password; 20 } 21 22 public void setPassword(String password) { 23 this.password = password; 24 } 25 26 public String execute() throws Exception { 27 if (getUsername().equals("xingoo") && getPassword().equals("123")) { 28 ActionContext.getContext().getSession().put("user", getUsername()); 29 return SUCCESS; 30 }else{ 31 return ERROR; 32 } 33 } 34 }
mess.properties
loginPage=loginPage errorPage=errorPage succPage=succPage failTip=sorry,login failed succTip=welcome{0},login success user=username pass=password login=login 复制代码