关于struts2中的action
来源:互联网 发布:php href参数 编辑:程序博客网 时间:2024/06/11 20:55
struts2 继承了webwoek的核心优势使得完全脱离了servlet 下面简单介绍struts2中的action
1.action类将可以是一个普通的类实现自己的控制业务逻辑也可以实现action接口实现action接口将方便我们使用里面的方法
package struts2;
public class loginaction {
String username;
String userpwd;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserpwd() {
return userpwd;
}
public void setUserpwd(String userpwd) {
this.userpwd = userpwd;
}
public String execute()throws Exception{
if(getUsername().equals("lingkai")&&getUserpwd().equals("123")){
return "success";
}else{
return "error";
}
}
}
说明:logion实现了action业务逻辑也可以实现action接口来实现业务逻辑
package struts2;
public class loginaction implements Action {
String username;
String userpwd;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserpwd() {
return userpwd;
}
public void setUserpwd(String userpwd) {
this.userpwd = userpwd;
}
public String execute()throws Exception{
if(getUsername().equals("lingkai")&&getUserpwd().equals("123")){
return SUCCESS ;
}else{
return ERROR;
}
}
}
说明:在实际开发中我们可以体会到实现action接口的好处他为我们返回了一个succes或error常量通(这个常量是在接口中已经声明好了的)常我们都尽量避免返回一个字符串
- 关于struts2中的action
- 关于Struts2 Action中的setter&&getter
- 关于struts2中的default-action-ref
- 【Struts2】②关于Action
- Struts2中的Action
- struts2中的action单元测试
- struts2中的action单元测试
- struts2 action中的默认设置
- Struts2中的Action
- Struts2中的Action
- Struts2中的Action
- Struts2中的Action
- struts2中的action标签
- Struts2中的Action
- struts2中的Action详解
- struts2中的Action
- Struts2中的Action
- Struts2中的action类
- reverse
- Ajax无刷新自动发送邮件
- IT人二手挖掘机购买实录(上)
- DNA Sorting-PKU ACM 1007
- 区组设计
- 关于struts2中的action
- Red Hat 下 安装 Apache Mysql PHP
- 远程桌面
- 服务器搭建
- GridView 没数据显示表头
- 《程序员修炼之道》学习(一)
- 位运算补充
- 设计模式之简单工厂模式
- 学习iPhone开发中 sqlite3的使用