【发布时间】:2017-07-16 11:14:15
【问题描述】:
我正在使用 Spring 框架开发一个 maven 项目。
我更喜欢使用 <spring:message .../> 标记并将我的消息注册到 .properties 文件中,而不是在 JSP 中编写原始文本。
我在请求页面时收到此警告:
找不到 MessageSource 的 ResourceBundle [messages]:不能 查找基本名称消息的捆绑包,区域设置 fr
这会带来关于未找到消息的异常(显然)。
这是我项目的层次结构:
这是我的 springapp-servlet.xml :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="app.core" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/">
</property>
<property name="suffix" value=".jsp">
</property>
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<property name="defaultLocale" value="fr" />
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
<mvc:resources mapping="/public/**" location="/WEB-INF/resources/"
cache-period="31556926"/>
<mvc:annotation-driven />
</beans>
【问题讨论】:
标签: spring maven properties messages resourcebundle