Jsf Mojarra 2.2.3编码请求参数
问题始于我将Mojarra从2.2.1升级到2.2.3(JBoss Wildfly Alpha升级到Beta版) 当我试图提交带有特殊字符(波兰字母)的表单(POST)时,它们没有正确的UTF-8编码 我做了什么Jsf Mojarra 2.2.3编码请求参数,jsf,encoding,jboss,mojarra,Jsf,Encoding,Jboss,Mojarra,问题始于我将Mojarra从2.2.1升级到2.2.3(JBoss Wildfly Alpha升级到Beta版) 当我试图提交带有特殊字符(波兰字母)的表单(POST)时,它们没有正确的UTF-8编码 我做了什么 写了一个过滤器 @WebFilter(urlPatterns = "/*", initParams = { @WebInitParam(name = "ignore", value = "true" ), @WebInitParam(name = "encoding", value
- 写了一个过滤器
@WebFilter(urlPatterns = "/*", initParams = { @WebInitParam(name = "ignore", value = "true" ), @WebInitParam(name = "encoding", value = "UTF-8") }) public class CharacterEncodingFilter implements Filter { private String encoding = null; private FilterConfig filterConfig; // Should a character encoding specified by client be ignored private boolean ignore = true; @Override public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; this.encoding = filterConfig.getInitParameter("encoding"); String value = filterConfig.getInitParameter("ignore"); this.ignore = ((value == null) || value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes")); } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if ((ignore || (request.getCharacterEncoding() == null)) && (encoding != null)) { request.setCharacterEncoding(encoding); response.setCharacterEncoding(encoding); } chain.doFilter(request, response); } @Override public void destroy() { this.encoding = null; this.filterConfig = null; } }
- 每个XHTML都包含一行
- 布局还包含有关编码的信息
- 向standalone.xml添加属性
<property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/> <property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/> <property name="file.encoding" value="UTF-8"/>
这里有一个关于此的错误: 这里有一个可能的解决方案: 在web.xml中的过滤器后添加此选项:
<filter-mapping>
<filter-name>CDI Conversation Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
会话过滤器
/*
如下所述:
问候,
马丁问题出在牵引下编码
这里的解决方案:当我在解析请求时转储堆栈跟踪时,没有任何焊接包的跟踪。所有的东西都是通过下拖的。
<filter-mapping>
<filter-name>CDI Conversation Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>