title: Spring boot (default tomcat) URL parser error how to return json data
body: <p>I use spring boot build a restful application.</p>
  
  <p>When I request the url
  <code>http://localhost:8089/base/tollnames?type=2&amp;&amp;name=%&amp;admin_name=HK</code> (not be encoded) with postman tool, default tomcat return errors:</p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: Could not get HttpServletRequest URI: Malformed escape pair at index 57: http://localhost:8089/smapapi/base/tollnames?type=2&amp;amp;name=%&amp;amp;admin_name=%E5%8C%97%E4%BA%AC
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:980)
  org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:870)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  java.lang.IllegalStateException: Could not get HttpServletRequest URI: Malformed escape pair at index 57: http://localhost:8089/smapapi/base/tollnames?type=2&amp;amp;name=%&amp;amp;admin_name=%E5%8C%97%E4%BA%AC
  org.springframework.http.server.ServletServerHttpRequest.getURI(ServletServerHttpRequest.java:99)
  org.springframework.web.util.UriComponentsBuilder.fromHttpRequest(UriComponentsBuilder.java:282)
  org.springframework.web.util.WebUtils.isSameOrigin(WebUtils.java:814)
  org.springframework.web.cors.DefaultCorsProcessor.processRequest(DefaultCorsProcessor.java:71)
  org.springframework.web.servlet.handler.AbstractHandlerMapping$CorsInterceptor.preHandle(AbstractHandlerMapping.java:503)
  org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:954)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
  org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:870)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  java.net.URISyntaxException: Malformed escape pair at index 57:     localhost:8089/smapapi/base/tollnames?type=2&amp;amp;name=%&amp;amp;admin_name=%E5%8C%97%E4%BA%AC
  java.net.URI$Parser.fail(URI.java:2827)
  java.net.URI$Parser.scanEscape(URI.java:2957)
  java.net.URI$Parser.scan(URI.java:2980)
  java.net.URI$Parser.checkChars(URI.java:2998)
  java.net.URI$Parser.parseHierarchical(URI.java:3090)
  java.net.URI$Parser.parse(URI.java:3032)
  java.net.URI.&amp;lt;init&amp;gt;(URI.java:595)
  org.springframework.http.server.ServletServerHttpRequest.getURI(ServletServerHttpRequest.java:96)
  org.springframework.web.util.UriComponentsBuilder.fromHttpRequest(UriComponentsBuilder.java:282)
  org.springframework.web.util.WebUtils.isSameOrigin(WebUtils.java:814)
  org.springframework.web.cors.DefaultCorsProcessor.processRequest(DefaultCorsProcessor.java:71)
  org.springframework.web.servlet.handler.AbstractHandlerMapping$CorsInterceptor.preHandle(AbstractHandlerMapping.java:503)
  org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:134)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:954)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:968)
  org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:870)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
  org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:844)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
  org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121)
  org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  </code></pre>
  
  <p>I hope tomcat return json error, I really don't want those errors are exposed.</p>
  
  <p>If the url be encoded <code>http://localhost:8089/base/tollnames?type=2&amp;&amp;name=%25&amp;admin_name=HK</code> request is OK.</p>