I tried your code,it's fine.
But that's form post and page display function,not a json interface.
When I switched to json commute way,I got same wrong..
On Jan 24, 2008 2:04 PM, Rob Heittman <[EMAIL PROTECTED]> wrote:
> Here is the code I'm using to test, and it round trips your test data fine
> in Firefox and Camino:
>
> root.attach("/zhform", new Restlet(getContext()){
>
> public void handle(Request request, Response response){
> response.setEntity("<html><body><form method='post'
> action='zhproc'>"
> +"city: <input type='text' size='40'
> name='test1'/><br/>"
> +"street <input type='text' size='40'
> name='test2'/><br/>"
> +"<input type='submit'/>"
> +"</form></body></html>", MediaType.TEXT_HTML);
>
> response.getEntity().setCharacterSet(CharacterSet.valueOf("GBK"));
> }
> });
>
> root.attach("/zhproc", new Restlet(getContext()){
>
> public void handle(Request request, Response response){
> CharacterSet csin = request.getEntity().getCharacterSet();
> if(csin!=null)
> System.out.println (">>> Incoming character set is
> "+csin.getName());
> else
> System.out.println(">>> No incoming character set
> detected");
> // Force to the charset we are actually receiving. If I set
> this *wrong* I get
> // gibberish
>
> request.getEntity().setCharacterSet(CharacterSet.valueOf("GBK"));
> System.out.println(">>> Character set reset to
> "+request.getEntity().getCharacterSet().getName());
> Form f = new Form(request.getEntity());
> response.setEntity("<html><body>"
> +"city: "+f.getFirstValue("test1")+"<br/>"
> +"street: "+f.getFirstValue("test2")+"<br/>"
> +"</body></html>",MediaType.TEXT_HTML);
> // I can set any output encoding and it appears to render OK
>
> response.getEntity().setCharacterSet(CharacterSet.valueOf("GBK"));
> }
> });
>
> So I put your test data into the form at /zhform, and it spits back readable
> and fine on /zhproc ... I tried it on Camino and Safari with no trouble. Do
> you know what I might be missing in order to reproduce the issue you are
> seeing?
>
> - Rob
>
--
cleverpig
Location: Beijing
Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China
Zipcode: 100031
Phone: 010-66415588-1113
MSN: [EMAIL PROTECTED]
QQ: 149291732
Skepe: cleverpigatmatrix
My Facebook ID:cleverpig
My Blog: hihere.sohu.com
My Tags: del.icio.us/cleverpig
My Twitter: twitter.com/cleverpig
My Organization: www.beijing-open-party.org
一些值得关注的唧歪:
http://jiwai.de/t/jmatrix/
http://jiwai.de/t/db4o/
http://jiwai.de/t/matrix-community/