2014-12-08 6 views
1

SocialgraphUI-servlet.xml에자원 번들은

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:mvc="http://www.springframework.org/schema/mvc" 
     xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-4.0.xsd"> 

     <context:component-scan base-package="socialgraphui.controller" /> 

     <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
      <property name="prefix" value="/WEB-INF/jsp/" /> 
      <property name="suffix" value=".jsp" /> 
      <property name="viewClass" 
         value="org.springframework.web.servlet.view.JstlView" /> 
     </bean> 

     <mvc:annotation-driven> 
     <mvc:message-converters> 
      <bean class="org.springframework.http.converter.json.GsonHttpMessageConverter" /> 
     </mvc:message-converters> 
     </mvc:annotation-driven> 

     <mvc:resources mapping="/scripts/**" location="/scripts/" /> 
     <mvc:resources mapping="/styles/**" location="/styles/" /> 
     <mvc:resources mapping="/fonts/**" location="/fonts/" /> 
     <mvc:resources mapping="/images/**" location="/images/" /> 

     <!-- Spring MVC Message Source --> 
     <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> 
      <property name="useCodeAsDefaultMessage" value="true"/> 
      <property name="basenames"> 
       <list> 
        <value>content.socialGraph</value> 
       </list> 
      </property> 
     </bean> 

    </beans> 

의 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 

<groupId>cz.ario</groupId> 
<artifactId>socialgraphui</artifactId> 
<version>1.0-SNAPSHOT</version> 
<packaging>war</packaging> 

<name>socialgraphui</name> 

<properties> 
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <spring.version>4.1.0.RELEASE</spring.version> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>javax</groupId> 
     <artifactId>javaee-web-api</artifactId> 
     <version>6.0</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.google.guava</groupId> 
     <artifactId>guava</artifactId> 
     <version>18.0</version> 
     <type>jar</type> 
    </dependency> 
    <dependency> 
     <groupId>jstl</groupId> 
     <artifactId>jstl</artifactId> 
     <version>1.2</version> 
    </dependency> 
    <dependency> 
     <groupId>com.google.code.gson</groupId> 
     <artifactId>gson</artifactId> 
     <version>2.2.4</version> 
    </dependency> 
    <dependency> 
     <groupId>uk.com.robust-it</groupId> 
     <artifactId>cloning</artifactId> 
     <version>1.7.4</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-orm</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>${spring.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>${spring.version}</version> 
     <type>jar</type> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc-portlet</artifactId> 
     <version>${spring.version}</version> 
     <type>jar</type> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.3.2</version> 
      <configuration> 
       <source>1.8</source> 
       <target>1.8</target> 
       <compilerArguments> 
        <endorseddirs>${endorsed.dir}</endorseddirs> 
       </compilerArguments> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.1.1</version> 
      <configuration> 
       <failOnMissingWebXml>false</failOnMissingWebXml> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.1</version> 
      <executions> 
       <execution> 
        <phase>validate</phase> 
        <goals> 
         <goal>copy</goal> 
        </goals> 
        <configuration> 
         <outputDirectory>${endorsed.dir}</outputDirectory> 
         <silent>true</silent> 
         <artifactItems> 
          <artifactItem> 
           <groupId>javax</groupId> 
           <artifactId>javaee-endorsed-api</artifactId> 
           <version>6.0</version> 
           <type>jar</type> 
          </artifactItem> 
         </artifactItems> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

리소스 번들 파일 봄 4.1에서 작동하지 않습니다 경로는 src/main/resources/content/socialGraph.properties이이 파일에 하나 개의 속성입니다

socialgraph.panel.filter.time.header=Time 

내가 .jsp로 파일에서이 속성을 사용할 는 속성이 매핑되지 않은 및 H4 요소는 .jsp로 파일의 소스 코드와 함께 렌더링 :

<h4> <spring:message code="socialgraph.panel.filter.time.header" /> </h4> 
+0

으로 변경해야 할 수도 있습니다. 기본 이름 값은 입니다 .SocialGraph입니다. SocialGraph가되어서는 안됩니다 ... 부수적으로 낙타의 경우 여야합니다 : socialGraph – jny

+0

왜 낙타의 경우입니까? 번들 파일의 이름을 socialgraph.properties로 변경해야한다는 것을 의미합니까? – Matt

+0

예, 나는 메시지 소스 파일의 이름은 일반적으로 내가 content.socialGraph에 기본 이름의 파일 변경 값을 이름 – jny

답변

1

나는 봄 4를 사용하고이 내가 그것을

 <bean id="messageSource" 
     class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
     <property name="basename" value="classpath:messages" /> 
     <property name="defaultEncoding" value="UTF-8" /> 
    </bean> 

내 속성 파일이 자원 폴더 바로 아래에있다 할 방법이다. 귀하의 경우 기본 이름 값을 classpath:content/socialGraph

+0

응답 해 주셔서 감사합니다. 나는 그것을 시도했지만, 결과는 여전히 동일하다. – Matt

+1

ur JSP에서 '<% @ taglib prefix = "spring"uri = "http://www.springframework.org/tags"%>'를 사용 했습니까? – abiieez

+0

그것은 그 것이었다. 고맙습니다. – Matt