2014-04-14 31 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。也许你的意思是语言环境?

相关问题