我有一个控制器,该控制器必须返回带有俄语名称的JSON字符串,但我得到的答复是????? (无效字符)。
@Controller
public class ManifestController {
@ResponseBody
@RequestMapping(value = {"/manifest.json","/manifest"}, method = { RequestMethod.GET }, produces = {MediaType.APPLICATION_JSON_VALUE})
public String getManifestJson(
HttpServletRequest request)
{
Employee e= new Employee ();
e.setName("Мегафон Игры");
return JsonUtil.jsonStringify(e); //it converts object to json using JsonObjectMapper
}
}
答案 0 :(得分:0)
我在我的机器上尝试过,而且可以正常工作
User e = new User();
e.setFirstName("Мегафон Игры");
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json;
json = ow.writeValueAsString(e);
return json;
我所得到的:
{
"id": 0,
"creationDate": null,
"username": null,
"firstName": "Мегафон Игры",
"lastName": null,
"email": null,
"updateDate": null,
"active": 0
}