springmvc国际化问题

上帝门口的排队 发布于 2013/08/27 00:11
阅读 644
收藏 0

我配置了国际化

<!-- 国际化支持 -->
	<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'.


这是为什么呢?



加载中
0
Beyond-Bit
Beyond-Bit

Using message bundles

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
返回顶部
顶部