I have a database(MySql) hosted in Linux server on cloud. And my Java application deployed on same server. I have data in database which i am displaying in my html.
When i hit the API from application hosted on LINUX server i get junk characters
like(|���59���6���20������
) in the response body.
And when i connect my local application in intellij to the same LINUX database i am getting proper response response from my local application in postman(|毓59年6月20日缸
).
My response actually contains Japanese character.
What i have tried?
- Change char set in browser.
- Encode the String in java using UTF-8 charset.
In both the response from local machine and LINUX response headers are same. Only Response body differs. I have no idea what the actual issue is.
My sample code is below. I cannot post actual code here.
@Autowired
private EncryptionService encryptionService;
@Autowired
private IdentifierRepository identifierRepository;
private ApplicantRepository applicantRepository;
@GetMapping("applicant/{applicantId}/identifier/{identifierId}")
public ResponseEntity<Identifier> getIdentifier(@PathVariable long applicantId,@PathVariable long identifierId){
Identifier identifier = identifierRepository.findIdentifierById(identifierId);
identifier.setOcrResponse(encryptionService.decrypt(identifier.setOcrResponse()));
return ResponseEntity.ok(identifier);
}
@PostMapping("applicant/{applicantId}/identifier")
public ResponseEntity<Identifier> callbackUrl(@RequestBody Map<String,String> map,@PathVariable long applicantId){
Identifier identifier = new Identifier();
identifier.setApplicant(applicantRepository.findById(applicantId));
identifier.setOcrResponse(encryptionService.encrypt(map.get("abbyOcr")));
identifierRepository.save(identifier);
ResponseEntity.noContent();
}
Actually we are getting response as a callback from abby ocr and saving it to db after encryption.
These are the request headers.
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,hi;q=0.8
accessToken: 272f8807-f6c9-4bc4-9ba4-8082532e9364
Cache-Control: no-cache
Connection: keep-alive
Host: 10.132.214.204:8191
Origin: http://10.132.214.204:8080
Pragma: no-cache
Referer: http://10.132.214.204:8080/dob/
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36
and these are the response header from linux
Access-Control-Allow-Origin: *
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Type: application/json;charset=UTF-8
Date: Wed, 20 Nov 2019 11:52:24 GMT
Expires: 0
Pragma: no-cache
Set-Cookie: JSESSIONID=174FB7AF3BC28922D3169DE1BB12612E; Path=/; HttpOnly
Transfer-Encoding: chunked
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Anybody please suggest me how resolve this issue