Question

I have a problem with HttpServletRequest when I send a params which has a value = "Hành động". But I use String categoryName = request.getParameter("categoryname");

Param categoryName will be "Hành ??ng". I don't understand that error.

Somebody help me???

Was it helpful?

Solution

Try to apply following filter on your servlet:

public class EncodingFilter implements Filter {

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    if (request.getCharacterEncoding() == null) {
        request.setCharacterEncoding("UTF-8");
    }

    if (chain != null) {
        chain.doFilter(request, response);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top