我配置了国际化
<!-- 国际化支持 --> <mvc:interceptors> <ref bean="localeChangeInterceptor" /> </mvc:interceptors> <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> <property name="paramName" value="locale" /> </bean> <bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver"></bean> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename"> <value>messages</value> </property> </bean>
jsp部分代码:
<spring:message code="login.title"/>
访问方式1:
http://localhost:8080/testi18n/hello.do(访问直接返回jsp)
访问方式2:
http://localhost:8080/testi18n/index.jsp
方式1可以正常,但是方式2就报异常了
javax.servlet.jsp.JspTagException: No message found under code 'login.title' for locale 'zh'.
这是为什么呢?
Internationalized messages are defined in message bundles accessed by a Spring MessageSource. To create a flow-specific message bundle, simply define messages.propertiesfile(s) in your flow's directory. Create a default messages.properties file and a .properties file for each additional Locale you need to support.
#messages.properties checkinDate=Check in date must be a future date notHealthy={0} is bad for your health reservationConfirmation=We have processed your reservation - thank you and enjoy your stay
From within a view or a flow, you may also access message resources using the resourceBundle EL variable:
<h:outputText value="#{resourceBundle.reservationConfirmation}" />
对照一下,你的方法是否满足spring mvc Internationalized messages
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。