Tomcat does not decrypt URL-encoded string

I am sending the URL of the encoded data to the jsp page (Tomcat Behind) from my iphone application (encoded using the following method):

- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)enc NS_AVAILABLE(10_3, 2_0);

And String Encoding is used as parameter: NSUTF8StringEncoding

But for some reason, this data is incorrectly decoded.

Sample Text : Β₯£€>€£

Encoded: %C2%A5%C2%A3%E2%82%AC%3E%E2%82%AC%C2%A3

Received on Cell As SMS: Β₯ Β£ Ξ¦ > Ξ¦  Β£

So, it seems that a few characters are not encoded / decoded.

Any idea what I am missing?

+3
source share
2 answers

URIs are encoded as UTF-8, but Tomcat decrypts them as ISO-8859-1 . You need to edit the connector settings in server.xml and add the attribute URIEncoding="UTF-8".

+7
source

Spring characterEncodingFilter, McDowell, url- "/*". *.do

  <filter>
    <filter-name>characterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
      <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
      <param-name>forceEncoding</param-name>
      <param-value>true</param-value>
    </init-param>
  </filter>

  <filter-mapping>
    <filter-name>characterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
0

Source: https://habr.com/ru/post/1796364/


All Articles