我在我的項目中使用了Spring集成。我正在使用<int-http:outbound-gateway>
執行休息服務。我的休息網址包含幾個特殊字符,如#
和&
。確切的網址是http://XXX70:12345/amisys-soa/rest/clientd/providers/professional/JAMPANA#1&?v=1&eao=02062017
Spring集成出站網關不編碼URL
根據Spring集成規範,<int-http:outbound-gateway>
應默認對url進行編碼。所以,我的期望是,上面提到的網址應轉化爲http://XXX70:12345/amisys-soa/rest/clientd/providers/professional/JAMPANA%231%26?v=1&eao=02062017
即JAMPANA#1&
應該被編碼爲JAMPANA%231%26
但在現實中,這不會發生,網址爲根本不受<int-http:outbound-gateway>
編碼。
爲什麼org.springframework.web.client.RestTemplate
沒有編碼我的網址?有沒有解決我的問題的方法?
我<int-http:outbound-gateway>
以下方式配置:
<int-http:outbound-gateway url-expression="headers.restResourceUrl"
http-method-expression="headers.httpMethod"
encode-uri="true"
expected-response-type="java.lang.String" >
</int-http:outbound-gateway>
一些片日誌低於:
2017-02-13 15:59:01,302 DEBUG main [org.springframework.web.client.RestTemplate] Created GET request for "http://XXX70:12345/amisys-soa/rest/clientd/providers/professional/JAMPANA#1&?v=1&eao=02062017"
2017-02-13 15:59:01,302 DEBUG main [org.springframework.web.client.RestTemplate] Setting request Accept header to [text/plain, application/json, application/*+json, */*]
2017-02-13 15:59:01,858 DEBUG main [org.springframework.web.client.RestTemplate] GET request for "http://XXX70:12345/amisys-soa/rest/clientd/providers/professional/JAMPANA#1&?v=1&eao=02062017" resulted in 200 (OK)
2017-02-13 15:59:01,858 DEBUG main [org.springframework.web.client.RestTemplate] Reading [java.lang.String] as "application/vnd.dsths.services-v1+xml" using [[email protected]569b73]
感謝您的澄清 –