Struts2 Action????????
???????????? ???????[ 2013/9/18 13:34:31 ] ????????
??????Struts2???е?????????struts 2.2.1.1??? ?????????struts2???а??е?struts2-junit-plugin-2.2.1.1.jar??????????????????StrutsTestCase??StrutsSpringTestCase??????????struts??ú?struts+spring????????????????????????????
????1.StrutsTestCase
????????????????struts2??????????????????????????μ???
????Account.java????bean
package model;
public class Account {
private String userName;
private String password;
public Account() {
}
public Account(String userName?? String password) {
this.userName = userName;
this.password = password;
}
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;
}
}
????AccountAction.java
package action;
import com.opensymphony.xwork2.ActionSupport;
import model.Account;
import java.util.logging.Logger;
public class AccountAction extends ActionSupport{
private Account accountBean;
public String execute() throws Exception {
return SUCCESS;
}
public void validate(){
if (accountBean.getUserName().length()==0){
addFieldError("accountBean.userName"??"User name is required.");
}
if (accountBean.getUserName().length()<5){
addFieldError("accountBean.userName"??"User name must be at least 5 characters long.");
}
if (accountBean.getUserName().length()>10){
addFieldError("accountBean.userName"??"User name cannot be at more thant 10 characters long.");
}
}
public Account getAccountBean() {
return accountBean;
}
public void setAccountBean(Account accountBean) {
this.accountBean = accountBean;
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11