> [EMAIL PROTECTED] wrote:
>>>> I have problem to show chinese characters stored in MySQL database
>>>> with
>>>> use of struts bean tag. Data is read out using Hibernate. When I call
>>>> myHibernateObject.getMyProperty() method - everything works fine. But
>>>> using <bean:write name="myHibernateObject" property="myProperty"/>
>>>> does
>>>> show text in this notation: &#xxxx &#xxxx. Same problem occurres when
>>>> I
>>>> use this bean in struts form with <html:text name="myHibernateObject"
>>>> property="myProperty"/>
>>>>
>>>> Encoding of database is set up properly to gb2312. JSP page uses UTF-8
>>>> encoding. How can I set character encoding for struts bean tag ? Or
>>>> where
>>>> is the problem ?
>>> How are you verifying that what you get back from the database is
>>> correct? If anywhere in the data retrieval pipeline is using the wrong
>>> encoding, you'll get corrupted data. Try hard-coding an output value to
>>> see if you are able to display that correctly.
>>>
>>> If that fails, it must be something in the way you've written your JSP;
>>> make sure that you have the UFT-8 charsett declared in the content type
>>> of the response -- e.g. with <%@ page contentType="text/html;
>>> charset=UTF-8"%> and/or HTML META-tags.
>>>
>>> L.

So, here the most important part of my JSP code:

<head>
<html:base/>
<title>test</title>
<META http-equiv="Content-Type" content="text/html;charset=UTF-8">
</head>

<%

/*
* +++ TEST CASE 1 +++
*/

// business logic for obtaining all hibernated objects
BOGeneric bo = new BOGeneric();
List l = bo.find("ChinaText", new Criterion[] {}, new Order[] {});
pageContext.setAttribute("names", l);

// runs it throung and prints out all the texts
for (Iterator i=l.iterator(); i.hasNext();) {
        out.println(((ChinaText)i.next()).getText() + " : ");
}
%>

<!--
+++ TEST CASE 2 +++
now the same using struts
-->
<logic:iterate id="chinatext" collection="<%=l%>">
        <bean:write name="chinatext" property="text"/> -
</logic:iterate>

In the first test case I get correct encoded chinese texts. In the second
one I get only &#xxxx strings.

>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>
>> I have verified it with <%=myObject.getProperty()%> in the JSP. In this
>> case I got chinese string with right encoding. But using <bean:write
>> name="myObject" property="property"/> produces string in this wrong
>> encoding format: &#xxxx. Charset of the JSP page is set to UTF-8.
>
> In that case I'm not sure what's going on... Can you post a short JSP
> fragment that demonstrates the problem?
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



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

Reply via email to