Action bean cannot get correct utf-8 character

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Action bean cannot get correct utf-8 character

Emi Lu
Hello,

For struts2.5.14.1, I have an issue with utf-8 encoding (jsp submit to
action class; bean get wrong character).

(1) web.xml
<jsp-config>
     <jsp-property-group>
         <url-pattern>*.jsp</url-pattern>
         <page-encoding>UTF-8</page-encoding>
     </jsp-property-group>
</jsp-config>


     <filter>
     <display-name>set character encoding</display-name>
<filter-name>setCharacterEncodingFilter</filter-name>
<filter-class>SetCharacterEncodingFilter</filter-class>
     <init-param>
     <param-name>encoding</param-name>
     <param-value>UTF-8</param-value>
     </init-param>
     </filter>

    <filter-mapping>
<filter-name>setCharacterEncodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>


(2) jsp page
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<s:form accept-encoding="UTF-8">
<s:textarea name='test'>

Value entered é in jsp


(3) Action bean get value:               é.


Can someone let me know what config is wrong/missing please?

Thanks a lot!

Reply | Threaded
Open this post in threaded view
|

Re: Action bean cannot get correct utf-8 character

Yasser Zamani-2


On 12/19/2017 1:38 AM, Emi wrote:
> Value entered é in jsp
>
>
> (3) Action bean get value:               é.
>
>
> Can someone let me know what config is wrong/missing please?

Have you checked your container (e.g. tomcat, jetty, etc) config? for
example in tomcat, add "URIEncoding="UTF-8" attribute to your Connector
in server.xml. like `<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"  redirectPort="8443" URIEncoding="UTF-8"/>` [1].

I hope this helps.

[1] https://wiki.apache.org/tomcat/FAQ/CharacterEncoding

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]