Daniil,
There was a thread in February IIRC on this and solutions were
mentioned. End-to-end "UTF-8" support requires multiple layers.
If you are looking at simply posting data and having it encoded in
"UTF-8" then AFAIK Stripes already performs
request.setCharacterEncoding(...) passing in the result of the call to
getCharacterEncoding() (if I recall the method name correctly) and is
easily subclassed in your own LocalePicker. I simply hard code that
method to return "UTF-8" as I deal with many languages and only care
about enabling "UTF-8".
The filter should be unnecessary and some have argued that the filter
provides a generic foundation for enabling "UTF-8" support across
multiple frameworks and projects. I'd be curious to see why this
doesn't work with Stripes but would need to see your custom LocalePicker
and if necessary web.xml (if you set the character encoding in web.xml
vs. hard coding in your custom LocalePicker).
Cheers,
--Nikolaos
Daniil Sosonkin wrote:
After writing to the group, I've managed to fix the problem! Solution
was to add request.setCharacterEncoding("UTF-8"); in my filter. After
that - it all works peaches.
On 5/3/2011 1:43 PM, Daniil Sosonkin wrote:
Hi all - I've been out of this for some time, but now back to UTF-8
issue with Stripes and mySQL. First and foremost, I'd like to resolve
Stripes on this topic. In my case, I'm interested in UTF-8 and only
in UTF8. No other character sets will appear as we're are
international. I have partial success, not enough to proceed to
production. It seems as if I'm missing something.
Here's how I test it. There's MyLocalePicker which picks picks
appropriate Locale and ALWAYS returns encoding as UTF-8. I have no
problems outputting UTF-8 text because header is always set to:
Content-type: text/html;charset=UTF-8. Necessary JSPs that contain
UTF, have proper pageEncoding set on them as well.
Then I have very very simple test.jsp that takes the text.
<s:form beanclass="com.orbis.web.actions.Test">
<s:text name="str" /><s:submit name="add" />
</s:form>
The action bean looks as following:
package com.orbis.web.actions;
import com.orbis.web.*;
import net.sourceforge.stripes.action.*;
@UrlBinding("/test.action")
public class Test extends MyActionBean
{
private String str;
public String getStr()
{
return str;
}
public void setStr(String str)
{
this.str = str;
}
public Resolution test() throws SQLException
{
return new ForwardResolution("/test2.jsp");
}
}
And test2.jsp looks as simple as the following:
<%--@elvariable id="actionBean" type="com.orbis.web.actions.Test"--%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s"
uri="http://stripes.sourceforge.net/stripes-dynattr.tld" %>
<%@ taglib prefix="o" uri="/TLDs/tags.tld" %>
<%@ page isELIgnored="false" %>
Added: ${actionBean.str}
The problem is that resulting text is all grumbled. The success comes
when I change setStr to the following:
this.str = new String(str.getBytes("ISO-8859-1"), "UTF-8");
Then text becomes true UTF and result of action bean is all fine. The
problem with that solution is that I don't want to do it, I'd like to
have Stripes do that for me. I really think that its not problem with
Stripes, but I did something wrong and not utilizing Stripes
correctly. Will happily provide source to MyLocalePicker if needed.
BTW - tomcat 7.0.11 server.xml contains URIEncoding="UTF-8" for GET
requests.
We sort of need to resolve this as we have to start supporting
international input and not just output.
Thank you,
Daniil
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
------------------------------------------------------------------------
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users
--
Nikolaos Giannopoulos
Director, Information Technology
BrightMinds Software Inc.
e. nikol...@brightminds.org
w. www.brightminds.org
t. 1.613.822.1700
c. 1.613.797.0036
f. 1.613.822.1915
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users