Struts Message Resources小記
配置Message Resources的兩種方式:
1.在web.xml中配
2.在struts-confg.xml中
如果要在資源文件中定義一個動態的內容,像“hello:月芽兒”
可以如下:
1.在web.xml中配
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>


<param-value>
com.hunau.liuyong.struts.ApplicationResources
</param-value>


</init-param>
</servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>


<param-value>
com.hunau.liuyong.struts.ApplicationResources
</param-value>


</init-param>
</servlet>
2.在struts-confg.xml中
<message-resources parameter="com.hunau.liuyong.struts.ApplicationResources"/>
如果要在資源文件中定義一個動態的內容,像“hello:月芽兒”
可以如下:
message.hello=hello:{0}
在頁面引用時傳一個參數給它就OK<bean:message key="message.hello" arg0="月芽兒"/>
如果不止一個參數就{1}{2}對應arg1 arg2posted on 2007-09-13 15:10 月芽兒 閱讀(636) 評論(0) 編輯 收藏 所屬分類: J2EE學習心得