Hello,
Using Struts 2.1.6
Tomcat 6
Java 1.6
Eclipse Ganymede
I am trying to get my first Struts2 application working. Everything works fine
except the encoding part. Swede as I am I want to use åäöÅÄÖ, i.e. ISO-8859-1,
but it doesn't work.
I have searched the net and tried various things, but I think this is pointing
in the correct direction so I did as explained (but that person used UTF-8
instead):
I created following file:
public class EncodingFilter implements Filter{
private String encoding = "ISO-8859-1";
@Override
public void destroy() {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException {
request.setCharacterEncoding(encoding);
response.setCharacterEncoding(encoding);
filterChain.doFilter(request, response);
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub
String encodingParam = filterConfig.getInitParameter("encoding");
if (encodingParam != null) {
encoding = encodingParam;
}
}
}
My JSP files has this
and this
I added following part to web.xml
EncodingFilter
org.nicsoft.utilities.EncodingFilter
encoding
ISO-8859-1
EncodingFilter
/*
I assume I don't have to do anything else in order to get it working with
doFiler, the application server automatically request the doFilter, correct?
I am also using Hibernate for storing data that I post from the form in MySQL.
However, I am quite sure that Hiberante has nothing to do with the problem
because I am doing I am writing the parameters to the console before Hibernate
hooks in.
Can anyone help out, I have no idea how to proceed. I couldn't find any good
how-to for this problem or posts on any forum. The best was the one I explained
above.
Thank you in advance!
Best Regards,
Niklas
_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]