论坛首页 Java企业应用论坛

struts2配置文件中读取propertites文件的内容

浏览 2811 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-06-20   最后修改:2012-06-20
在Spring中, 可以在xml的配置文件中读取propertites属性文件中的值,如下设置:
    <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location">
            <value>/WEB-INF/init.properties</value>
        </property>
    </bean>


读取的时候如下:
       
<property name="username">
            <value>${datasource.username}</value>
        </property>



请问Struts2的xml文件中能读取propertites文件中的属性么?
有人的作法是,要读取UserAction.propertites文件的内容, 就建一个UserAction类, 通过父类ActionSupport的getText()方法读取,不过这样只能在JSP页面中读取吧, 在xml配置文件中怎么读呢?


<s:param name="request_locale" value="%{getText(xxx.xxx)}" />




刚刚去查了下  Struts2-default.properties 文件,  里面有个 struts.custom.properties属性来加载用户自定义的属性文件, 但是还没找到怎么读取。

struts.custom.properties

该属性指定Struts2应用加载用户自定义的属性文件,该自定义属性文件指定的属性不会覆盖struts.properties文件中指定的属性。如果需要加载多个自定义属性文件,多个自定义属性文件的文件名以英文逗号(,)隔开。

论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics