2017-02-25 2 views
0

저는 스프링 프레임 워크를 사용하여 maven 프로젝트를 만들고 있습니다.스프링에서 messages.properties를 찾지 못했습니다.

JSP에 원시 텍스트를 쓰는 대신. <spring:message .../> 태그를 사용하고 .properties 파일에 내 메시지를 등록하는 것을 선호합니다. MessageSource를 찾을 수 없습니다

의 ResourceBundle [메시지] : 수는 기본 이름이 메시지에 대한 찾기 번들, 로케일 FR

다음 제공하지 않는 페이지를 요청하면

나는이 경고를 얻을 발견되지 않는 메시지에 대한 예외 (분명히).

여기 내 프로젝트의 계층 구조입니다 :

<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> 

답변

1

the documentation에서 :

basename이이 ResourceBundle의 규칙을 따르

my project's hierarchy

가 여기 내 springapp-servlet.xml 파일의 본질적 정규화 된 classpath 위치입니다. 패키지 한정자 (예 : org.mypackage)가 포함되어 있지 않으면 클래스 경로 루트에서 확인됩니다.

는 그래서 src/main/resources에서

(강조 광산을)해야한다.

+0

효과가있었습니다. 감사 ! 내 IDE (intellij 아이디어)가 basename 값에 대해 경고하더라도. –

관련 문제