1

I have a Spring-based RESTful API which is deployed to a Tomcat server. When I call this API like below (value of "para" has been URL-encoded) and debug it, value of "para" in controller method is "aaa bbb" which has already been URL-decoded.

However, when I run a SpringBoot-based local Test Automation case (not deployed anywhere) to test the same API, the value of "para" in controller method hasn't been URL-decoded.

Question is, what is the difference between the two scenarios and where is "para" URL-decoded in the first scenario?

yasi
  • 451
  • 7
  • 18

1 Answers1

0

Hopefully I can give you a hint for the first part of your question:

The Apache Tomcat server.xml contains an tag Connector, this tag can have an optional attribute URIEncoding. Example:

<Connector connectionTimeout="20000"
           port="8080"
           protocol="HTTP/1.1"
           redirectPort="8443"
           URIEncoding="UTF-8" />

So I think that Tomcat is responsible for the URI encoding. But I do not know how this is activated in an Embedded-Spring-Boot-Tomcat.

Ralph
  • 118,862
  • 56
  • 287
  • 383
  • I didn't find such attribute configured in my Tomcat server.xml. – yasi Nov 15 '17 at 08:13
  • "If not specified, UTF-8 will be used unless the org.apache.catalina.STRICT_SERVLET_COMPLIANCE system property is set to true in which case ISO-8859-1 will be used", so, the default attribute of "UTF-8" does the URL decoding here. – yasi Nov 15 '17 at 08:15
  • I do not know the actual default behaviour. But I have to set this property in some older Tomcat versions explicit to UTF-8 to turn on UTF-8 encoding. – Ralph Nov 15 '17 at 08:19