2014-04-14 42 views
0

我需要設置Spring MVC交叉鏈接來抓取url參數language並相應地從.properties文件中獲取數據。收到錯誤Cannot resolve property PARAMNAME在servlet-config.xml配置上下文時:無法解析Spring MVC中的屬性`paramName`

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:mvc="http://www.springframework.org/schema/mvc" 
     xmlns:p="http://www.springframework.org/schema/p" 
     xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd 
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> 

    <mvc:annotation-driven/> 

    <mvc:resources mapping="/pdfs" location="pdfs"/> 

    <context:component-scan base-package="com.ttu.cs.controller"/> 

    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" p:basename="messages" /> 

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
      p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /> 

    <bean id="LocaleResolver" class="org.springframework.web.servlet.i18n.SessionLocaleResolver" p:defaultLocale="en"/> 

    <!-- Declare the Interceptor --> 
    <mvc:interceptors> 
     <bean class="org.springframework.web.servlet.i18n.SessionLocaleResolver"> 
      <property name="paramName" value="language"/> 
     </bean> 

    </mvc:interceptors> 
</beans> 
+0

這意味着類org.springframework.web.servlet.i18n.SessionLocaleResolver沒有名爲'paramName'的屬性 – Jay

回答

1

我想你的意思是使用org.springframework.web.servlet.i18n.LocaleChangeInterceptor而不是SessionLocaleResolver

<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> 
    <property name="paramName" value="language"/> 
</bean> 

這個類是HandlerInterceptor確實有一個paramName財產。

SessionLocaleResolver另一方面,不是。

-1

不知道你期待什麼,但SessionLocaleResolver沒有這樣的PARAM。也許你的意思是語言環境?

相關問題