exceptionaction.java
来自「关于Struts2的初体验」· Java 代码 · 共 53 行
JAVA
53 行
package com.test.actions;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;
import com.test.exception.PassWordException;
import com.test.exception.UserNameException;
@SuppressWarnings("serial")
public class ExceptionAction extends ActionSupport {
private String userName = "";
private String 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;
}
@Override
public String execute() throws Exception {
// 检查用户名
if (! "Panda逍遥".equals(this.getUserName())) {
throw new UserNameException("用户名错误!!");
// 检查密码
} else if (! "systemtao".equals(this.getPassword())) {
throw new PassWordException("密码错误!!");
} else {
return Action.SUCCESS;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?