request.getQueryString() seems to need some encoding

前端 未结 5 1244
盖世英雄少女心
盖世英雄少女心 2020-11-28 05:35

I have some problem with UTF-8. My client (realized in GWT) make a request to my servlet, with some parametres in the URL, as follow:

http://localhost:8080/s         


        
5条回答
  •  情深已故
    2020-11-28 05:41

    It really took all day but :

    final String param = new String(request.getParameter("param").getBytes(
                    "iso-8859-1"), "UTF-8");
    

    See also here. Note that this is valid iff the decoding charset (URIEncoding in tomcat) of the server is iso-8859-1 - otherwise this charset must be passed in. For an example of how to get the URIEncoding charset from the server.xml for Tomcat 7 see my quoted answer

提交回复
热议问题