0

I want to delete this metadata : "déééé"

I have this HTTP REQUEST :

DELETE /test/api/metadata/d%C3%A9%C3%A9%C3%A9%C3%A9 HTTP/1.1
Host: localhost:8585
Connection: keep-alive
Accept: application/json, text/plain, */*
Origin: http://localhost:8585
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
Referer: http://localhost:8585/test/
Accept-Encoding: gzip, deflate, sdch
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: JSESSIONID=4f789...

I have this Mapping Controller :

  @RequestMapping(value = "metadata/{categoryName}", produces = "application/json", method = DELETE)
  public @ResponseBody boolean deleteMetadata(@PathVariable String categoryName) { 
      return test.deleteCategory(categoryName);
  }

but in my controller i get this : déééé so wrong encoding

in my web.xml i have this :

<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>

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

what is missing ?

1
  • you tried setting the contentType of the request to application/json;charset=UTF-8 from your client? Just seems to me the request is messed up already before going to the server. Commented Feb 27, 2015 at 13:32

1 Answer 1

1

The encoding of the URL is defined by the server. If you use Tomcat then somewhere in your server.xml you have the setup for the connectors. Just add the preferred encoding:

<Connector port="8080" URIEncoding="UTF-8" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.