Problems with UTF-8 encoding, JSP, jQuery, Spring

后端 未结 2 1584
死守一世寂寞
死守一世寂寞 2021-02-10 04:27

I have a web app with spring,jsp and jquery in a apache tomcat 6, one jsp page has a form that send the data with a ajax call made whit jquery, to a Spring MultiActionController

2条回答
  •  北海茫月
    2021-02-10 05:26

    I had the same problem from with Characters and I solved it the following way:

    request.setCharacterEncoding("utf-8");
                    StringBuffer requestContent = new StringBuffer();
                    do
                    {
                        bytesRead = request.getInputStream().readLine(bytes,0,bytes.length);
                        if(bytesRead > 0)
                        {
                            requestContent.append(new String(bytes,0,bytesRead,"UTF-8"));
                        }
                    }
                    while(bytesRead > 0);
    

    and then fetch from requestContent your string started with "name="

提交回复
热议问题