struts2
来源:互联网 发布:实战最强的武术知乎 编辑:程序博客网 时间:2024/06/06 03:03
<span style="font-size: large;">package com.javacrazyer.web.action;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ExceptionMapping;
import org.apache.struts2.convention.annotation.ExceptionMappings;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import com.opensymphony.xwork2.ActionSupport;
/**
* 使用注解来配置Action
*
*/
@ParentPackage("struts-default")
// 父包
@Namespace("/user")
@Results( { @Result(name = "success", location = "/msg.jsp"),
@Result(name = "error", location = "/error.jsp") })
@ExceptionMappings( { @ExceptionMapping(exception = "java.lange.RuntimeException", result = "error") })
public class LoginAction extends ActionSupport {
private static final long serialVersionUID = -2554018432709689579L;
private String loginname;
private String pwd;
@Action(value = "login")
public String login() throws Exception {
if ("qq".equals(loginname) && "123".equals(pwd)) {
return SUCCESS;
} else {
return ERROR;
}
}
@Action(value = "add", results = { @Result(name = "success", location = "/index.jsp") })
public String add() throws Exception {
return SUCCESS;
}
public String getLoginname() {
return loginname;
}
public void setLoginname(String loginname) {
this.loginname = loginname;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
}</span>
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ExceptionMapping;
import org.apache.struts2.convention.annotation.ExceptionMappings;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import com.opensymphony.xwork2.ActionSupport;
/**
* 使用注解来配置Action
*
*/
@ParentPackage("struts-default")
// 父包
@Namespace("/user")
@Results( { @Result(name = "success", location = "/msg.jsp"),
@Result(name = "error", location = "/error.jsp") })
@ExceptionMappings( { @ExceptionMapping(exception = "java.lange.RuntimeException", result = "error") })
public class LoginAction extends ActionSupport {
private static final long serialVersionUID = -2554018432709689579L;
private String loginname;
private String pwd;
@Action(value = "login")
public String login() throws Exception {
if ("qq".equals(loginname) && "123".equals(pwd)) {
return SUCCESS;
} else {
return ERROR;
}
}
@Action(value = "add", results = { @Result(name = "success", location = "/index.jsp") })
public String add() throws Exception {
return SUCCESS;
}
public String getLoginname() {
return loginname;
}
public void setLoginname(String loginname) {
this.loginname = loginname;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
}</span>
0 0
- Struts2
- struts2
- struts2
- Struts2
- struts2
- struts2
- Struts2
- struts2
- struts2
- struts2
- Struts2
- Struts2
- Struts2
- struts2
- struts2
- STRUTS2
- Struts2
- Struts2
- Java_Exception_异常
- 浅议运行时
- 日经春秋 20151227
- Linux下用户组、文件权限详解
- Java_log4j_使用开源日志记录工具log4j
- struts2
- js,jQuery复选框勾选总结
- VS2010运行结果报错error LNK2038: 检测到“_ITERATOR_DEBUG_LEVEL”的不匹配项: 值“0”不匹配值“2”
- Android对话框显示后自动消失
- js追加事件执行代码场景
- RPC最全总结
- 记JAVA的二三事(2)——JVM存储区+hashCode()和equals()的隐式约定
- rsync 实现文件备份同步
- 对于Automake和autoconf联合生成makefile文件的一些个人认识