Spring Integration HTTP Outbound Gateway URI变量替换与编码问题
Let's work through your two Spring Integration HTTP Outbound Gateway issues step by step:
Your first error — EL1001E: Type conversion problem, cannot convert from java.lang.String to java.lang.Integer — happens because the maxCount value from your payload is being treated as a String, but the URI variable expects an Integer type.
Looking at your original configuration:
<int-http:outbound-gateway url="https://ia-zatie.str13.tst.bnst.nh/ia-zaatie/rest/signan/v2/wg/{workgroupId}//actionType/New?max={maxCount}" http-method="GET" header-mapper="headerMapper" expected-response-type="java.lang.String" request-factory="sslFactory" > <int-http:uri-variable name="workgroupId" expression="payload['workgroupId']" /> <int-http:uri-variable name="maxCount" expression="payload['maxCount']"/> </int-http:outbound-gateway>
If your payload is a raw JSON string (not a parsed Map or Java object), accessing payload['maxCount'] returns a String representation of the number. To fix this, explicitly convert it to an Integer in the SpEL expression:
<int-http:uri-variable name="maxCount" expression="T(Integer).valueOf(payload['maxCount'])"/>
Alternatively, if you control the payload pipeline, parse the JSON into a Map<String, Object> or a dedicated domain object before sending it to the gateway. This way, payload['maxCount'] will already be an Integer, eliminating the conversion error entirely.
? Your second problem — where ? gets encoded to %3F — stems from trying to cram query parameters into a path variable. Spring Integration automatically URL-encodes path variable values to comply with URI path rules, which is why your ? gets turned into %3F.
Instead of building query parameters into your payload and using a path variable, handle them separately with one of these approaches:
Option 1: Use <int-http:query-parameter> for query params
Keep the path variable for the workgroup ID, and add a dedicated query parameter for max:
<int-http:outbound-gateway url="https://ia-zatie.str13.tst.bnst.nh/ia-zaatie/rest/signan/v2/wg/{workgroup}/actionType/New" http-method="GET" header-mapper="headerMapper" expected-response-type="java.lang.String" request-factory="sslFactory" > <int-http:uri-variable name="workgroup" expression="payload.workgroupId" /> <int-http:query-parameter name="max" expression="payload.maxCount" /> </int-http:outbound-gateway>
(This assumes your payload is now a parsed object/Map with workgroupId and maxCount fields.)
Option 2: Build the full URI dynamically with uri-expression
If you need full control over the URI structure, use uri-expression instead of a static url attribute. This lets you construct the entire URI without automatic encoding of valid query string characters:
<int-http:outbound-gateway uri-expression="'https://ia-zatie.str13.tst.bnst.nh/ia-zaatie/rest/signan/v2/wg/' + payload.workgroupId + '/actionType/New?max=' + payload.maxCount" http-method="GET" header-mapper="headerMapper" expected-response-type="java.lang.String" request-factory="sslFactory" />
Why your original approach failed
Path variables are meant for segments of the URI path (the part before the ?), so Spring encodes any special characters to keep the path valid. Query parameters belong in the query string section of the URI, so they need to be defined separately or included directly in a dynamic URI expression.
内容的提问来源于stack exchange,提问作者Kris Swat

