我为我的applecation配置了这个Spring配置,如下所示
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang"/>
</bean>
</mvc:interceptors>
<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
id="messageSource"
p:basename="resources/l18n/label"/>
<bean
class="org.springframework.web.servlet.i18n.CookieLocaleResolver"
id="localeResolver"
p:cookieName="locale"
p:defaultLocale="en"/>
当我运行我的应用程序默认lang总是ru虽然我设置en(p:defaultLocale="en"
)当我更改后缀我的URL ?lang=en
没有任何改变,一切也是ru。当我试图删除label_ru
时,我得到了这个例外:
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.servlet.jsp.JspTagException: No message found under code 'jumbotron.h1' for locale 'ru'
Web.xml:
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Phone Book</display-name>
<welcome-file-list>
<welcome-file>/WEB-INF/views/index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/servlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
答案 0 :(得分:0)
为避免此问题,您的shoudt不会在web.xml文件中使用以下标记
<welcome-file-list>
<welcome-file>/WEB-INF/views/index.jsp</welcome-file>
</welcome-file-list>