users@jersey.java.net

Re: [Jersey] Setting response encoding

From: Suneel Marthi <suneel_marthi_at_yahoo.com>
Date: Sun, 13 Jun 2010 05:05:05 -0700 (PDT)

Try this: @Produces(MediaType.TEXT_HTML;MediaType.ACCEPT_CHARSET="UTF-8") ________________________________ From: Franz Wong <franzwong_at_gmail.com> To: users_at_jersey.dev.java.net Sent: Sun, June 13, 2010 4:20:44 AM Subject: [Jersey] Setting response encoding Hi, I am dealing with a multilingual problem. When I redirected to a jsp page, the non English characters cannot be shown correctly. e.g. "靜夜思" (Chinese characters) would become "???" However, there is no problem with English characters. How can I set the encoding to UTF-8? Here is the sample code. The service class @GET @Produces(MediaType.TEXT_HTML) public Viewable retrieve() { // some code here // response is a POJO response.setText("靜夜思"); // Non English characters here System.out.println(response.getText()); // The characters are correctly displayed in the console return new Viewable("/jsp/result.jsp", response); } The jsp <input type="text" readonly="true" value="${it.text}"/> I am using version 1.1.5.1. Thanks. Franz