public class AjaxEncodeFilter extends HttpServlet implements Filter {
/**
* AJAX使用中的字符过滤器解决中文问题
*/
private static final long serialVersionUID = L;
public void doFilter(ServletRequest servletRequest
ServletResponse servletResponse FilterChain filterChain)
throws IOException ServletException {
/* if (loggerisDebugEnabled()) {
loggerdebug(doFilter(ServletRequest ServletResponse FilterChain) start) //$NONNLS$
} */
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
String requestedWith = requestgetHeader(xrequestedwith)
String type = requestgetContentType()
if (requestedWith != null && XMLHttpRequestequals(requestedWith)
&& null != type
&& application/xwwwformurlencodedequals(type)) {
// (Thiss ajax postset encode is UTF)
requestsetCharacterEncoding(UTF)
responsesetCharacterEncoding(UTF)
requestgetParameterMap()
}
filterChaindoFilter(request response)
/* if (loggerisDebugEnabled()) {
loggerdebug(doFilter(ServletRequest ServletResponse FilterChain) end) //$NONNLS$
} */
}
public void init(FilterConfig arg) throws ServletException {
// TODO Autogenerated method stub
}
}