我将印地语存储在数据库中。
在我的提取方法中,我使用的是objectMapper
,它将印地语字体转换为特殊字符。没有objectmapper
的话就可以了
@CrossOrigin
@RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> fetchDepartmentInfo() {
try {
List<Map<String, Object>> departmentList = departmentServices.fetchDepartments();
if (departmentList == null || departmentList.isEmpty())
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
else
return new ResponseEntity<String>(new ObjectMapper().writeValueAsString(departmentList), HttpStatus.OK);
} catch (Exception e) {
System.out.println(e);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
o / p:
[
{
"department": "?? ?? ?????",
"departmentId": 1
}
]
但是应该是:
[
{
"department": "जल कल विभाग",
"departmentId": 1
}
]
最佳答案
刚刚将mediaType更改为APPLICATION_JSON_UTF8_VALUE
@CrossOrigin
@RequestMapping(value = "", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<?> fetchDepartmentInfo() {
try {
List<Map<String, Object>> departmentList = departmentServices.fetchDepartments();
if (departmentList == null || departmentList.isEmpty())
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
else
return new ResponseEntity<String>(new ObjectMapper().writeValueAsString(departmentList), HttpStatus.OK);
} catch (Exception e) {
System.out.println(e);
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
}
它解决了我的问题。
关于java - objectMapper将印地文文本转换为特殊字符“???”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45397929/