/** * The default behavior of this method is to set the character encoding * on the wrapped request object. */ public void setCharacterEncoding(String enc) throws java.io.UnsupportedEncodingException { this.request.setCharacterEncoding(enc); }
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException { request.setCharacterEncoding("UTF-8"); chain.doFilter(request, response); }
/** * Sets the character encoding to be used for any content passing out of this filter. */ @Override 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); } }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding(Constants.ENCODE); response.setContentType("application/json;charset=" + Constants.ENCODE); try { chain.doFilter(request, response); } catch (IOException ioe) { defaultLog.debug("Filter catch exception, " + ioe.toString(), ioe); throw ioe; } catch (ServletException se) { defaultLog.debug("Filter catch exception, " + se.toString(), se); throw se; } }
/** * Select and set (if specified) the character encoding to be used to * interpret request parameters for this request. * * @param request servlet request we are processing * @param response servlet response we are creating * @param chain filter chain we are processing * * @exception IOException * if an input/output error occurs * @exception ServletException * if a servlet error occurs */ @Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { // Conditionally select and set the character encoding to be used if (ignore || (request.getCharacterEncoding() == null)) { String encodingStr = selectEncoding(request); if (encodingStr != null) { request.setCharacterEncoding(encodingStr); response.setCharacterEncoding(encodingStr); } } chain.doFilter(request, response); }
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { if (!(servletRequest instanceof HttpServletRequest) || !(servletResponse instanceof HttpServletResponse)) { throw new ServletException("Resty doesn't support non-HTTP request or response."); } servletRequest.setCharacterEncoding(encoding); servletResponse.setCharacterEncoding(encoding); HttpRequest request = new HttpRequest((HttpServletRequest) servletRequest, restyIniter.getServletContext()); HttpResponse response = new HttpResponse((HttpServletResponse) servletResponse, (HttpServletRequest) servletRequest); boolean[] isHandled = {false}; //排除的参数 if (!isExclusion(request.getRestPath())) { try { handler.handle(request, response, isHandled); } catch (Exception e) { ExceptionHolder.HOLDER.hold(request, response, e, isHandled); } finally { response.close(); } } if (!isHandled[0]) { chain.doFilter(servletRequest, servletResponse); } }
/** * The default behavior of this method is to set the character encoding * on the wrapped request object. */ public void setCharacterEncoding(String enc) throws java.io.UnsupportedEncodingException { this.request.setCharacterEncoding(enc); }
/** * The default behavior of this method is to set the character encoding * on the wrapped request object. */ public void setCharacterEncoding(String enc) throws UnsupportedEncodingException { this.request.setCharacterEncoding(enc); }
import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; public class CharacterEncodingFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { servletRequest.setCharacterEncoding("UTF-8"); servletResponse.setContentType("text/html; charset=UTF-8"); filterChain.doFilter(servletRequest, servletResponse); } @Override public void destroy() { } }
/** * Sets the request and response encoding to a given charset. * * @param request the specified request * @param response the specified response * @param chain filter chain * @throws IOException io exception * @throws ServletException servlet exception */ @Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding(requestEncoding); response.setCharacterEncoding(responseEncoding); chain.doFilter(request, response); }
/** * Select and set (if specified) the character encoding to be used to * interpret request parameters for this request. * * @param request The servlet request we are processing * @param result The servlet response we are creating * @param chain The filter chain we are processing * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet error occurs */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // Conditionally select and set the character encoding to be used if (ignore || (request.getCharacterEncoding() == null)) { String encoding = selectEncoding(request); if (encoding != null) request.setCharacterEncoding(encoding); } // Pass control on to the next filter chain.doFilter(request, response); }
/** * The default behavior of this method is to set the character encoding * on the wrapped request object. */ public void setCharacterEncoding(String enc) throws UnsupportedEncodingException { this.request.setCharacterEncoding(enc); }
/** * The default behavior of this method is to set the character encoding on * the wrapped request object. */ @Override public void setCharacterEncoding(String enc) throws java.io.UnsupportedEncodingException { this.request.setCharacterEncoding(enc); }
/** * The default behavior of this method is to set the character encoding * on the wrapped request object. */ public void setCharacterEncoding(String enc) throws UnsupportedEncodingException { this.request.setCharacterEncoding(enc); }
/** * The default behavior of this method is to set the character encoding * on the wrapped request object. */ public void setCharacterEncoding(String enc) throws java.io.UnsupportedEncodingException { this.request.setCharacterEncoding(enc); }
/** * @see ExternalContext#setRequestCharacterEncoding(String) */ public void setRequestCharacterEncoding(String encoding) throws UnsupportedEncodingException { request.setCharacterEncoding(encoding); }
/** * @since JSF 1.2 * @param encoding * @throws java.io.UnsupportedEncodingException */ @Override public void setRequestCharacterEncoding(final java.lang.String encoding) throws java.io.UnsupportedEncodingException { this._servletRequest.setCharacterEncoding(encoding); }
request.setCharacterEncoding("UTF-8"); if (logger.isDebugEnabled()) { logger.debug("set request.characterEncoding by default:"
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws ServletException, IOException { if ( encoding!=null && ( overrideClient || request.getCharacterEncoding() == null ) ) { request.setCharacterEncoding(encoding); } filterChain.doFilter(request, response); }
/** {@inheritDoc} */ @Override public void setCharacterEncoding(String enc) throws UnsupportedEncodingException { super.getRequest().setCharacterEncoding(enc); }