Tôi đã tạo một dịch vụ web còn lại nhỏ bằng Jersey 1.11. Khi tôi gọi url trả về Json, có vấn đề với mã hóa ký tự cho các ký tự không phải tiếng Anh. Url tương ứng cho Xml ("test.xml" làm cho nó utf-8 trong bắt đầu xml-tag.dịch vụ web jersey mã hóa json utf-8
Làm thế nào tôi có thể làm cho url "test.json" trở lại phản ứng utf-8 mã hóa?
Dưới đây là mã cho các dịch vụ:
@Stateless
@Path("/")
public class RestTest {
@EJB
private MyDao myDao;
@Path("test.xml/")
@GET
@Produces(MediaType.APPLICATION_XML)
public List<Profile> getProfiles() {
return myDao.getProfilesForWeb();
}
@Path("test.json/")
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Profile> getProfilesAsJson() {
return myDao.getProfilesForWeb();
}
}
Đây là POJO rằng dịch vụ sử dụng:
package se.kc.mimee.profile.model;
@XmlRootElement
public class Profile {
public int id;
public String name;
public Profile(int id, String name) {
this.id = id;
this.name = name;
}
public Profile() {}
}
thể trùng lặp của [? Làm thế nào để thiết lập charset với JAX-RS] (http://stackoverflow.com/questions/3431996/how -to-set-the-charset-với-jax-rs) – rds