我正在使用以下配置在Spring集成中创建api端点。
<int-http:inbound-gateway
request-channel="httpProjectRequest"
reply-channel="httpProjectResponce" supported-methods="GET"
path="/project/{key}" payload-expression="#pathVariables.key">
<int-http:request-mapping consumes="application/json" produces="application/json"/>
</int-http:inbound-gateway>
<int:service-activator
ref="projectAPI"
method="get"
input-channel="httpProjectRequest"
output-channel="httpProjectResponce"/>
我面临的问题是当我在
/project/DFV-1.1
URL上以“键”值发送GET请求时得到DFV-1
,当我在/project/DFV-1.1.1
上以键值发送GET请求时获得了DFV-1.1
为什么忽略最后一个点之后的值。
最佳答案
请像下面这样配置一个bean:
<beans:bean id="integrationRequestMappingHandlerMapping"
class="org.springframework.integration.http.inbound.IntegrationRequestMappingHandlerMapping">
<beans:property name="useSuffixPatternMatch" value="false"/>
</beans:bean>
useSuffixPatternMatch
说明:/**
* Whether to use suffix pattern match (".*") when matching patterns to
* requests. If enabled a method mapped to "/users" also matches to "/users.*".
* <p>The default value is {@code true}.
* <p>Also see {@link #setUseRegisteredSuffixPatternMatch(boolean)} for
* more fine-grained control over specific suffixes to allow.
*/
public void setUseSuffixPatternMatch(boolean useSuffixPatternMatch) {