zoukankan      html  css  js  c++  java
  • struts2 常量配置

         struts2的常量配置的方式有很多种,例如在struts.properties,struts.xml,web.xml中。

         通常,struts2框架按如下搜索顺寻加载struts2常量。

            (1) struts-default.xml: 该文件保存在struts2-core-版本号.jar文件中

            (2) struts-plugin.xml

            (3) struts.xml

            (4) struts.properties

            (5) web.xml

            注意: 如果在多个文件中同时配置了同一个常量,后面文件中的配置会覆盖前面文件的配置。

            在struts.xml文件中通过constant元素来配置常量,配置常量需要两个必须的属性,分别为name、value,大家一看也知道这两个属性的含义,一个指定常量的名字,一个指定常量的值,如下例:

           

    <struts>
         <constant name="struts.custom.i18n.resources" value="mess" />
    </struts>

              同样也可以在web.xml文件中通过<filter>元素的子元素<init-param>配置,将上例中的常量配置放在web.xml中如下:

    <filter>
    .......
    <init-param>
         <param-name>struts.custom.i18n.resources</param-name>
         <param-value>mess</param-value>
    </init-param>
    .......
    </filter>

     推荐在struts.xml文件中配置常量。

  • 相关阅读:
    处理火星文重温vchar,char,nvchar,nchar
    删除文件
    js常用正则表达式
    安装iis 配置iis
    无题
    js函数大全
    常用正则表达式
    QQ在线客服
    获取系统文字字体
    无限级删除的存储过程
  • 原文地址:https://www.cnblogs.com/binger/p/struts_constant.html
Copyright © 2011-2022 走看看