描述:
在struts的config文件里指定了多個屬性文件,如:
<message-resources parameter="ApplicationResources" />
<message-resources parameter="test.Resources" key="another"/>
定義了兩個屬性文件,一個放在默認的key下,一個放在key值“another”下。然后頁面中如下運用:
<bean:message key="search.name" bundle="another" />
將會出現錯誤:
Can’t find any message-resources under key “another”……..
然后無論你怎么改,怎么翻書找資料,都是郁悶就一個字啊!!
原因:
因為我們是按模塊來開發,所以會有多個struts的config文件,一個config文件對應一個模塊,比如,我們上面的config文件叫做struts-config_right.xml,是專門為right模塊編寫,即在web.xml中是這樣寫的:
<init-param>
<param-name>config/right</param-name>
<param-value>/WEB-INF/struts-config_right.xml</param-value>
</init-param>
所以呢,對于應用于缺省模塊的方法就不是很適用了(上面的方法是針對缺省模塊的,也不說明一下)。然后呢,根據我看struts源代碼知道的東西,是要這樣寫的(di,念第四聲):
<bean:message key="search.name" bundle="another/right" />
是不是很不爽啊?我就是覺得很不爽,要寫也應該是”right/another”吧,還是反過來的,唉。。。。