为什么Spring 3.x路径参数被截断

时间:2016-02-25 17:45:27

标签: spring spring-mvc spring-restcontroller spring-rest

路径参数值随机截断。

例如:myapplication / {pathparam}

实际值" ab-cd-626-1.2.3.4 .6"实际上解析为ab-cd-626-1.2.3.4。 不知道为什么会这样,请帮忙

2 个答案:

答案 0 :(得分:0)

我不是在使用那个pathparam的地方,可能是在控制器方法的@RequestMapping中?

我遇到了问题,当路径参数包含'。时,我完全避免这种情况。问题源于这种方式,网址是由春天解析的。

关于这方面的更多讨论:pathvariable with dot is getting truncated

答案 1 :(得分:0)

<bean id="contentNegotiationManager"
    class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
    <property name="favorPathExtension" value="false" />
    <property name="favorParameter" value="true" />
    <property name="mediaTypes">
        <value>
            json=application/json
            xml=application/xml
        </value>
    </property>
</bean>
<mvc:annotation-driven
    content-negotiation-manager="contentNegotiationManager">
    <mvc:path-matching suffix-pattern="false" registered-suffixes-only="true" />
</mvc:annotation-driven>