Very very strange.
I tried to encode Chinese first in javascript then sent to the component
event handler.
Javascript:
new Ajax.Request(spec.url,
{
method: 'post',
parameters: {content: encodeURIComponent('????')},
contentType:
"application/x-www-form-urlencoded; charset=UTF-8",
});
Event handler:
Object onContentChangeDetected(@RequestParameter("content") String content)
{
try
{
System.out.println(content);
System.out.println(URLDecoder.decode(content,"UTF-8"));
}
catch (Exception ex)
{
ex.printStackTrace();
}
return null;
}
I got this output:
%E6%B5%8B%E8%AF%95
?????? //these are bad characters
but when I test this in a separate class:
String str="%E6%B5%8B%E8%AF%95";
System.out.println(str);
System.out.println(URLDecoder.decode(str, "UTF-8"));
I got this:
%E6%B5%8B%E8%AF%95
???? //good result
How can this be explained?
?? 2012/5/18 9:56, Rural Hunter ????:
Hi,
I wrote a component which uses ajax request to trigger a component event:
new Ajax.Request(spec.url,
{
method: 'post',
parameters: {content: newContent}
});
In the event handler:
Object onContentChangeDetected(@RequestParameter("content") String
content)
{
System.out.println(content);
return null;
}
Now the problem is, the Chinese character I received in the event
handler turns into garbage characters. Both my page and tomcat are set
to use UTF-8. The Chinese in normal form inputs and even the
autocomplete mixin are correct. I checked the source of autocomplete
since the behavior of my component is somewhat like that. but I didn't
find any additional process on char encoding. Did I miss anything and
what's the best place to re-decoding/encoding the characters?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org