Zrobiłem mały serwis internetowy Rest za pomocą Jersey 1.11. Kiedy zadzwonię do adresu URL, który zwraca Json, pojawiają się problemy z kodowaniem znaków dla znaków spoza angielskiego. Odpowiedni adres URL XML ("test.xml" sprawia, że UTF-8 w wyjściowym xml-tag.serwis internetowy jersey json utf-8 kodowanie
Jak mogę dokonać url "test.json" powrót kodowanie UTF-8 odpowiedzi?
Oto kod dla usługi:
@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();
}
}
to pojo że usługa używa:
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() {}
}
możliwe duplikat [? Jak ustawić charset z JAX-RS] (http://stackoverflow.com/questions/3431996/how -to-set-the-charset-z-jax-rs) – rds