简体   繁体   中英

ResourceBundleMessageSource resolving error

I have a JSP-Tagfile which renders the html-header and defines my Javascript/Stylesheet resources.

<%@ tag language="java" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="<spring:theme code="main.css"/>"/>
    <script type="text/javascript" src="<spring:theme code="default.js"/>"></script>
...

</html>

Now i wan't to load a i18n messages for the javascript stuff.

var button_ok='<spring:message code="js.button.ok" javaScriptEscape="true"/>';

When i use this inside the tag-file it works as supposed and resolves the messages, even if there is only a default messages.properties (fallback).

But if i load the messages with an external javascript file lang.js.jsp it only tries to resolve the message code against the properties for the current language and the fallback to the default one is not working.

If the message should be resolved inside the tag, the ApplicationContext defined within the DispatcherServlet is used. Otherwise the ApplicationContext from the ContextLoaderListener is used (root application context).

To solve the problem i moved the ResourceBundleMessageSource into the configuration which is loaded by the ContextLoaderListener.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM