企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
web.xml ~~~ <context-param> <param-name>encode</param-name> <param-value>UTF-8</param-value> </context-param> ~~~ EncodingFilter ~~~ package com.neusoft.web.fiter; 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; import javax.servlet.annotation.WebFilter; /** * Servlet Filter implementation class EncodingFilter */ @WebFilter("/*") public class EncodingFilter implements Filter { public void destroy() { // TODO Auto-generated method stub } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String encode = fConfig.getServletContext().getInitParameter("encode"); request.setCharacterEncoding(encode); chain.doFilter(request, response); } private FilterConfig fConfig; public void init(FilterConfig fConfig) throws ServletException { this.fConfig = fConfig; } } ~~~