adolphusX 2016-12-07 03:44 采纳率: 0%
浏览 980

springmvc4.3.1配置annotation-driven后@RequestParam失效

现在使用springmvc4.3.1,要返回json,所以配置annotation-driven和引用json包后就正常使用了
但原来能用的@RequestParam就失效了,而@PathVariable能用,这是为什么呢?
下面是我的配置信息
spring-conf.xml




mvc:annotation-driven
mvc:message-converters




application/json;charset=UTF-8
text/html;charset=UTF-8
application/xml;charset=UTF-8



/mvc:message-converters
/mvc:annotation-driven

<bean id="freemarkerConfiguration"
    class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="location" value="classpath:freemarker.properties" />
</bean>

<!-- 配置freeMarker模板加载地址 -->
<bean id="freemarkerConfig"
    class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <!-- 视图解析器会在/WEB-INF/ftl/路径下扫描视图文件 -->
    <property name="templateLoaderPaths">
        <list>
            <value>/WEB-INF/ftl/json/</value>
            <value>/WEB-INF/ftl/html/</value>
        </list>
    </property>
    <property name="freemarkerVariables">
        <map>
            <entry key="xml_escape" value-ref="fmXmlEscape" />
        </map>
    </property>
</bean>

<bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape" />

<!-- FreeMarker视图解析 如返回userinfo。。在这里配置后缀名ftl和视图解析器。。 -->
<bean id="freemakerViewResolver"
    class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
    <property name="viewClass"
            value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
    <!-- 扫描路径內所有以ftl結尾的文件 -->
    <property name="viewNames">
        <array>
            <value>*.ftl</value>
        </array>
    </property> 
    <property name="contentType" value="text/html;charset=UTF-8" />
    <property name="exposeRequestAttributes" value="true" />
    <property name="exposeSessionAttributes" value="true" />
    <property name="exposeSpringMacroHelpers" value="true" />
    <property name="requestContextAttribute" value="request" />
    <property name="cache" value="true" />
    <property name="order" value="0" />
</bean>

pom.xml
<dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${com.fasterxml.jackson.core-version}</version>
    </dependency>
  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2016-12-10 15:43
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧