We have to do character encoding before calling ActionServlet.
So we have to use <filter> before ActionServlet.
@WebFilter(filterName="/CharacterEncodingFilter", urlPatterns="/*") public class CharacterEncodingFilter implements Filter { /** * Default constructor. */ public CharacterEncodingFilter() { // TODO Auto-generated constructor stub } /** * @see Filter#destroy() */ public void destroy() { // TODO Auto-generated method stub } /** * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); chain.doFilter(request, response); } /** * @see Filter#init(FilterConfig) */ public void init(FilterConfig fConfig) throws ServletException { // TODO Auto-generated method stub } }
No comments:
Post a Comment