UTF-8 encoding and http parameters

I am making a simple ajax call with YahooUI Javascript library as follows:

YAHOO.util.Connect.setForm('myform');
YAHOO.util.Connect.asyncRequest('POST', url, ...);

Below are the settings in my application: Tomcat version: 6.0.18

Tomcat Server Connector: URIEncoding = "UTF-8" Webpage:

Also listed in the YahooUI Connector Library documentation:

setForm will encode each HTML form field name and value using encodeURIComponent. This results in a UTF-8 encoding string, name-value pairs. NOTE. Setting the HTTP header "Content-Type" with a different encoding value will not change the encoding of serialized data.encoding of serialized data.

I see that the French characters that are sent as parameters are encoded (in ie7 using the iehttpheader utility):

    name=%C3%88%C3%A0%C3%B4 
    testParam=%C3%B4%C3%B4   

For data: name: ààô and testParam: "

: ÃÂàÃÂ

, :    String val = new String (oo.getBytes( "UTF-8" )); , .

. , : UTF-8, Java Webapps?./p >

UPDATE: UTF-8, W3.org http://www.w3.org/International/O-URL-code.html, . , Tomcat ?

+5
2

POST, URIEncoding="UTF-8" . , Tomcat, - UTF-8. , , Spring CharacterEncodingFilter (, Javadoc). .

+7

, :

package com.lfantastico.web;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class EncodingFilter implements Filter {
    private String encoding = "UTF-8";

    public void destroy() {
    }

    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {
        request.setCharacterEncoding(encoding);
        response.setCharacterEncoding(encoding);
        chain.doFilter(request, response);
    }

    public void init(FilterConfig config) throws ServletException {
        if (config.getInitParameter("encoding") != null) {
            encoding = config.getInitParameter("encoding");
        }
    }
}
+1

All Articles