Hi,

I am building a web application with Struts2 and Tomcat 5.5 as the web container. One action parameter is passed as part of the URL and may
contain Unicode characters:
<action name="article/*" class="...">
   <param name="title">{1}</param>
   <result>/ShowArticle.jsp</result>
</action>

The <s:url> tag encodes this parameter as UTF-8, and I declared in my tomcat server.xml the matching encoding
    <Connector URIEncoding="UTF-8" ... port="8081" />

So far, so good. Everything works fine. Trouble starts when I use redirect results or redirect-action result with Unicode characters in the title part of the url:

<action name="editarticle/*" class="...">
   <param name="title">{1}</param>
   <result name="save" type="redirect">article/${title}</result>
   ...
</action>

Than the redirect URL is encoded in ISO-8859-1, which is than misinterpreted as UTF-8 when send back to tomcat. While debugging I think this encoding is done in HTTPServletResponse#sendRedirect by default.

I can workaround that by introducing a new attribute to my action class:

public String getTitleURLEncoded() throws Exception {
  return URLEncoder.encode(getTitle(), "UTF-8");
}

and change the result to

<result name="save" type="redirect">article/${titleURLEncoded}</result>

This works, but it 'feels' wrong. Is there some other solution to this? Any input is welcome.

Best regards, Alex


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to