javascript

位置:IT落伍者 >> javascript >> 浏览文章

非常优秀的AJAX中文问题解决过滤器


发布日期:2023年05月07日
 
非常优秀的AJAX中文问题解决过滤器
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

}

}

上一篇:Seam 为JSF量身定做的应用程序框架

下一篇:如何使用Javascript XSLT 处理XML文件