Note that there are some explanatory texts on larger screens.

plurals
  1. POMojarra 2.2.3 encoding request parameters
    primarykey
    data
    text
    <p><strong>Problems started when I upgraded Mojarra from 2.2.1 to 2.2.3</strong> (JBoss Wildfly Alpha to Beta).</p> <p>When I try to submit a form (POST) with special characters (polish letters) they aren't properly UTF-8 encoded.</p> <p>What I have done?</p> <ul> <li><p>Wrote a filter</p> <pre><code>@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)) &amp;&amp; (encoding != null)) { request.setCharacterEncoding(encoding); response.setCharacterEncoding(encoding); } chain.doFilter(request, response); } @Override public void destroy() { this.encoding = null; this.filterConfig = null; } } </code></pre></li> <li><p>Every XHTML contains a line</p> <p><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;</code></p></li> <li><p>Layout also contains information about encoding</p> <p><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;</code></p></li> <li><p>Added properties to standalone.xml</p> <pre><code>&lt;property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/&gt; &lt;property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/&gt; &lt;property name="file.encoding" value="UTF-8"/&gt; </code></pre></li> <li><p>Logs in console when debugging request parameters from filter</p> <p><code>index_form:people: Tischner PrzemysÅaw</code></p> <p><code>index_form:j_idt66: index_form:j_idt66</code></p> <p><code>index_form: index_form</code></p> <p><code>index_form:dbId: 2881850</code></p> <p><code>javax.faces.ViewState: 2748560203387116963:2575775533048879716</code></p></li> <li><p>Request preview in browser <img src="https://i.stack.imgur.com/Z8tCX.png" alt="Request in Chrome"></p></li> <li><p>How I initialize JSF page</p> <pre><code>&lt;f:metadata&gt; &lt;f:viewParam name="name" value="#{followNewView.name}" /&gt; &lt;f:viewParam name="company" value="#{followNewView.company}" /&gt; &lt;f:viewParam name="companyURL" value="#{followNewView.companyURL}" /&gt; &lt;f:viewAction action="#{followNewView.init}" /&gt; &lt;/f:metadata&gt; </code></pre></li> </ul> <p>Finally I'm still ending with improper encoding: <img src="https://i.stack.imgur.com/77lKo.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload