java - Struts 2 parameter coding problem during redirect to another action -


i try redirect action , transmit string parameter. works without problems, have coding problem if using german umlauts.

here code: first action has field message getter , setter. in action set string.

private string message; public string action1() {      message = "ö";      return success; } 

second action has field message getter , setter too.

private string message; 

struts.xml definition of both actions

<action name="action" method="action1" class="de.samba.control.actions.action1"> <result name="success" type="redirectaction"> <param name="actionname">action2</param> <param name="message">${message}</param> 

<action name="action2" class="de.samba.control.actions.action2"> <result name="success">/pages/showmessage.jsp</result> 

if don´t using redirection , show message on jsp, works fine. coding correct. if redirect action setter of message field set wrong formattet string "ö". cannot found solution. can me please?

own filter:

<filter>    <filter-name>characterencodingfilter</filter-name>    <filter-class>de.samba.control.characterencodingfilter</filter-class> </filter>  <filter-mapping>    <filter-name>characterencodingfilter</filter-name>    <url-pattern>*.action</url-pattern> </filter-mapping> 

filter-class

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);  } } 

then tried filter:

<filter> <filter-name>encodingfilter</filter-name> <filter-class>org.springframework.web.filter.characterencodingfilter</filter-class>    <init-param>        <param-name>encoding</param-name>        <param-value>utf-8</param-value>    </init-param>    <init-param>        <param-name>forceencoding</param-name>        <param-value>true</param-value>    </init-param> </filter> 

this not work too. know problem? maybe caused spring security.

the problem tomcat issue , not struts issue. solution set uriencoding of connector "utf-8" in server.xml. see http://struts.apache.org/2.0.14/docs/how-to-support-utf-8-uriencoding-with-tomcat.html


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -