struts2开发action 的三种方法以及通配符、路径匹配原则、常量

时间:2023-03-09 16:29:02
struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struts2开发action 的三种方法

1、继承ActionSupport

public class UserAction extends ActionSupport {

    // Action中业务处理方法
public String login() {
System.out.println("UserAction.login()");
// return "success";
return SUCCESS;
}
}

2、实现Action

public class UserAction3 implements Action {

    // Action中业务处理方法
public String login() {
System.out.println("UserAction.login()");
return "success";
} @Override
public String execute() throws Exception {
return null;
}
}

3、既不继承也不实现任何的方法

public class UserAction {

    private String userName;
public void setUserName(String userName) {
this.userName = userName;
} // Action中业务处理方法
public String login() {
System.out.println("UserAction.login()" + userName);
return "login";
} public String register() {
System.out.println("register()" + userName);
return "register";
}
}

struts2开发action 的三种方法以及通配符、路径匹配原则、常量
struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struts2开发action 的三种方法以及通配符、路径匹配原则、常量 
动态方法调用

struts2开发action 的三种方法以及通配符、路径匹配原则、常量

struts2开发action 的三种方法以及通配符、路径匹配原则、常量