zoukankan      html  css  js  c++  java
  • struts2 之 Action的创建方式

    总结:struts2是一个轻量级框架,提供了无侵入性的实现方式,struts2也提供了接口和类来实现action。通过实现接口或者继承类来实现action可以实现struts2提供的相关功能,

    1. 通过Action接口来实现action:

      优点:限制了处理类必须有execute方法。在配置action中可以减少相关配置

    public class Hello1Action implements Action{
        public String execute() throws Exception {
            System.out.println("通过实现Action接口来实现处理类");
            return this.SUCCESS;
        }
    }

    2. 通过继承 struts2提供的ActionSupport类来实现处理类。这种方式可以使用到struts2提供的相关功能:验证,国际化。

    public class Hello2Action extends ActionSupport{
        public String hello(){
            System.out.println("hello 处理类");
            return this.SUCCESS;
        }
    }

    3.第三种实现处理类的方式就是无侵入性的实现。这种实现比较轻量级。

    public class Hello3Action{
        public String hello(){
            System.out.println("hello 处理类");
            return Action.SUCCESS;
        }
    }
  • 相关阅读:
    典型漏洞归纳之上传漏洞
    典型漏洞归纳之解析漏洞
    Python学习目录
    MySQL数据库优化的八种方式
    深度剖析Flask上下文管理机制
    算法十大排序(含动图)
    设计模式代码实例
    设计模式
    数据结构
    算法基础
  • 原文地址:https://www.cnblogs.com/forever2h/p/6708304.html
Copyright © 2011-2022 走看看