How to enable multiple message resources in Struts?

I use (training ...) Struts 1.3 to build an MVC web application. For clarity, I would like to include more than one element <message-resources>- the separation of messages into files for specific application modules.

The official Apache documentation says:

You can define one or more elements <message-resources>for your webapp; modules can define their own resource packages. Your application can use different packages at the same time, the key attribute is used to indicate the desired package.

However, when I include more than one element, the JSP raises an exception indicating that there is no message for the key:

SEVERE: Servlet.service() for servlet jsp threw exception javax.servlet.jsp.JspException: Missing message for key "label.username" in bundle "(default bundle)" for locale en_GB
at org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:233)
at org.apache.jsp.index_jsp._jspx_meth_bean_005fmessage_005f0(index_jsp.java:197)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:107) ~~~snip~~~

This is XML:

<struts-config>
    ~~~snip~~~
    <message-resources parameter="resources.DefaultResource"/>
    <message-resources parameter="resources.Registration"/>    
</struts-config>

"" . "label.username" "DefaultResource".

.

+3
3

struts-config ( ) , , . attnet bean:, , :

<struts-config>
    ~~~snip~~~
    <message-resources parameter="resources.DefaultResource"/>
    <message-resources parameter="resources.Registration" key="registrationBundle"/>    
</struts-config>

JSP:

Message from the default bundle : <bean:message key="my.first.key"/>
Message from the registration bundle : <bean:message key="my.second.key" bundle="registrationBundle"/>
+9

, . jsp . .

+2

, , . ,

, "" .

http://struts.apache.org/1.3.10/struts-core/dtddoc/struts-config_1_3.dtd.html#message-resources

( ) struts-config. , resources.Registration resources.DefaultResource
( , struts-config. label.username , )

+2

Source: https://habr.com/ru/post/1786962/


All Articles