zoukankan      html  css  js  c++  java
  • Struts2注解使用说明

    来源:http://blog.csdn.net/wk313753744/article/details/19920195

    1 Struts2注解的作用

    使用注解可以用来替换struts.xml配置文件!!!

    2 导包

      必须导入struts2-convention-plugin-2.3.15.jar包,它在struts2安装包下lib目录中。 

    3 通过配置文件学习对应的注解

    @Action来代替<action>元素!

    l  String value():指定访问路径;

    l  Result[] results():指定局部结果。

    @Result来代替<result>元素!

    l  String name():指定结果名称;

    l  String location():指定结果路径。

    @Namespace代替<package>的namespace属性:

    l  String value():指定名称空间。

    @ParentPackage代替<package>的extends属性:

    l  String value():指定父包名称

    @Namespace("/order")

    @ParentPackage("struts-default")

    publicclass OrderAction extends ActionSupport  {

        @Action(value="add", results={

               @Result(name="success", location="/index.jsp"),

               @Result(name="input", location="/add.jsp")})

        public String add() {

           System.out.println("add()");

           returnSUCCESS;

        }

        @Action(value="mod", results={@Result(name="success", location="/index.jsp")})

        public String mod() {

           System.out.println("mod()");

           returnSUCCESS;

        }

        @Action(value="del", results={@Result(name="success", location="/index.jsp")})

        public String del() {

           System.out.println("del()");

           returnSUCCESS;

        }

    }

    4 注解相关常量

      struts.convention.classes.reload,默认值为false。表示在修改注解后需要重启Tomcat!

  • 相关阅读:
    CPU的物理限制
    递归快还是循环(迭代)快?
    VS2010下测试程序性能瓶颈
    Qt编程之实现在QFileDialog上添加自定义的widget
    This application failed to start because it could not find or load the Qt platform plugin "windows"
    网络设备Web登录检测工具device-phamer
    Outlook数据提取工具readpst
    Xamarin无法调试Android项目
    Web应用扫描工具Wapiti
    Xamarin 2017.11.1更新
  • 原文地址:https://www.cnblogs.com/peiyangjun/p/8099797.html
Copyright © 2011-2022 走看看