struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Black <jeffrey.bl...@yahoo.com>
Subject Re: utf8 problems...
Date Mon, 14 Nov 2011 23:05:20 GMT
FWIW -- I know Matt Raible's AppFuse [1] uses Spring's CharacterEncodingFilter.

The blog-post [3] is just lagniappe.


Best,

jb

[1] http://appfuse.org/display/APF/Web+Filters

[2] http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/web/filter/CharacterEncodingFilter.html

[3] http://ibnaziz.wordpress.com/2008/06/10/spring-utf-8-conversion-using-characterencodingfilter/



________________________________
From: Maurizio Cucchiara <mcucchiara@apache.org>
To: Struts Users Mailing List <user@struts.apache.org>
Sent: Monday, November 14, 2011 4:56 AM
Subject: Re: utf8 problems...

Christian,
this is the filter I was talking about:

public class CharacterEncodingFilter implements Filter {
    private String encoding;

    public void destroy() {
    }

    public void doFilter(ServletRequest req, ServletResponse resp,
FilterChain chain) throws ServletException, IOException {
        resp.setCharacterEncoding(encoding);
        chain.doFilter(req, resp);
    }

    public void init(FilterConfig config) throws ServletException {
        encoding=config.getInitParameter("encoding");
    }

}
-----------------------------------------------------------------------------------------------------------------------------------
web.xml

   <filter>
         <filter-name>CharacterEncoding</filter-name>

<filter-class>com.dbi.norma.filter.CharacterEncodingFilter</filter-class>
         <init-param>
             <param-name>encoding</param-name>
             <param-value>UTF-8</param-value>
         </init-param>
     </filter>

    <filter-mapping>
        <filter-name>CharacterEncoding</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>

-----------------------------------------------------------------------------------------------------------------------------------
Furthermore IIRC struts2 usually takes into consideration the jsp page
directive, particolarly the contentType attribute:

<%@ page contentType="text/html; UTF-8" %>

OTH


Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 13 November 2011 18:31, Maurizio Cucchiara <mcucchiara@apache.org> wrote:

> Hi Christian,
> I have been using SM in production environments for a long time now.
> AFAIK 3.x is fairly stable though is still alpha.
> The encoding issues are my nightmare  :), you don't never know where
> they come from.
> The default encoding of S2 is UTF8, anyway to enforce the concept you
> could always do:
>
> <constant name="struts.i18n.encoding" value="UTF-8"/> (struts.xml)
>
> <parser content-type="text/html;charset=UTF-8"
> class="com.opensymphony.module.sitemesh.parser.HTMLPageParser" />
> (sitemesh.xml)
>
> I usually start from a very simple example, then go ahead (does your
> data display correctly without SM?).
> How did you import your data inside mysql?
>
> Ensure that your data was encoded correctly inside the DB itself:
> select hex(field) from Table where condition;
> As last option you can even consider a Character Encoding Servlet
> Filter, but to be frank I never felt the need to use it.
>
> Twitter     :http://www.twitter.com/m_cucchiara
> G+          :https://plus.google.com/107903711540963855921
> Linkedin    :http://www.linkedin.com/in/mauriziocucchiara
>
> Maurizio Cucchiara
>
>
>
> On 13 November 2011 17:35, Christian Grobmeier <grobmeier@gmail.com>
> wrote:
> > Hi guys,
> >
> > I am searching for a utf-8 problem in my app. I have struts 2 with
> > sitemesh 2.x bundled. backoffice is apache cayenne which connects to
> > mysql with:
> > &useUnicode=true&characterEncoding=utf8
> >
> > Now I suspect sitemesh somehow. Any ideas were I could look appreciated
> >
> > Is sitemesh still recommended btw? 2.x version is pretty old and 3.x
> > is in alpha for quite a while.
> >
> > Cheers
> > Christian
> >
> > --
> > http://www.grobmeier.de
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message