我在數據庫中存儲印地語。 在我的獲取方法中,我使用objectMapper
將印地文字體轉換爲特殊字符。沒有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
}
]
你確定這個腐敗發生在序列化到字符串期間,而不是在讀取輸入期間?首先使用調試器檢查'departmentList'包含正確的值。 – AlexR
當我刪除objectmapper它會返回預期的結果。所以是的,它與objectmapper的問題。 –