How do I set the default character encoding on my responses to UTF-8?
I\'ve tried this
System.setProperty(\"file.encoding\", \"UTF-8\");
<
I created character encoding filter to one legacy application.
public class CharacterEncodingFilter implements Filter {
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
if(req instanceof Request){
req.setCharacterEncoding("UTF-8");
}
chain.doFilter(req, res);
}
@Override
public void init(FilterConfig arg0) throws ServletException {
}
@Override
public void destroy() {
}
}
In web.xml filter-mapping has the url-pattern of /*. This routes all requests from the web application through the CharacterEncodingFilter.
CharacterEncoding
CharacterEncoding
my.app.filter.CharacterEncodingFilter
CharacterEncoding
/*