Note that there are some explanatory texts on larger screens.

plurals
  1. POStruts 2 parameter coding problem during redirect to another action
    primarykey
    data
    text
    <p>I try to redirect to another action and to transmit a string parameter. This works without problems, but I have a coding problem if I am using german umlauts.</p> <p>Here is my code: First action has a field message with getter and setter. In the action I set the String.</p> <pre><code>private String message; public String action1() { message = "ö"; return SUCCESS; } </code></pre> <p>Second action has a field message with getter and setter too.</p> <pre><code>private String message; </code></pre> <p>Struts.xml with the definition of the both actions</p> <pre><code>&lt;action name="action" method="action1" class="de.samba.control.actions.Action1"&gt; &lt;result name="success" type="redirectAction"&gt; &lt;param name="actionName"&gt;action2&lt;/param&gt; &lt;param name="message"&gt;${message}&lt;/param&gt; </code></pre> <p> </p> <pre><code>&lt;action name="action2" class="de.samba.control.actions.Action2"&gt; &lt;result name="success"&gt;/pages/showMessage.jsp&lt;/result&gt; </code></pre> <p></p> <p>If I don´t using redirection and show the message on a jsp, all works fine. The coding is correct. If I redirect to another action the setter of the message field set the wrong formattet string "ö". I cannot found the solution. Can somebody help me please?</p> <p>Own Filter:</p> <pre><code>&lt;filter&gt; &lt;filter-name&gt;CharacterEncodingFilter&lt;/filter-name&gt; &lt;filter-class&gt;de.samba.control.CharacterEncodingFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;CharacterEncodingFilter&lt;/filter-name&gt; &lt;url-pattern&gt;*.action&lt;/url-pattern&gt; &lt;/filter-mapping&gt; </code></pre> <p>Filter-class</p> <pre><code>public class CharacterEncodingFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain next) throws IOException, ServletException { String encoding = request.getCharacterEncoding(); if (encoding == null || encoding.length() == 0) { request.setCharacterEncoding("UTF-8"); } encoding = request.getCharacterEncoding(); next.doFilter(request, response); } } </code></pre> <p>Then I tried this filter:</p> <pre><code>&lt;filter&gt; &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt; &lt;init-param&gt; &lt;param-name&gt;encoding&lt;/param-name&gt; &lt;param-value&gt;UTF-8&lt;/param-value&gt; &lt;/init-param&gt; &lt;init-param&gt; &lt;param-name&gt;forceEncoding&lt;/param-name&gt; &lt;param-value&gt;true&lt;/param-value&gt; &lt;/init-param&gt; &lt;/filter&gt; </code></pre> <p>This does not work too. Do somebody know this problem? Maybe it is caused by Spring Security.</p>
    singulars
    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.
 

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