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文件中配置常量。

  • 相关阅读:
    zz 使用svn——项目的目录布局
    eclipse中字体太小
    SVN 项目的目录结构
    tuscany requires 学习
    搜索子集生成
    HZNUACM寒假集训Day12小结 数论入门
    HZNUACM寒假集训Day10小结 树树形DP
    模板 快速幂|取余
    HZNUACM寒假集训Day7小结 背包DP
    HZNUACM寒假集训Day6小结 线性DP
  • 原文地址:https://www.cnblogs.com/binger/p/struts_constant.html
Copyright © 2011-2022 走看看