我有一个 Angular 客户端,可以将表情符号发送到 Spring Boot Rest 客户端。
当我处理请求时,字符串字段中有脏字符。
如何获得表情符号?
这是控制器:
@UserAnnotation(value = UserType.A)
@PutMapping("/modify")
public ResponseEntity<ResponseController> modify(@Valid @RequestBody NovitaPojo novita) throws JsonProcessingException {
service.edit(novita);
return new ResponseEntity<>(ResponseController.buildOK(), HttpStatus.OK);
}
您可以通过以下任一方式处理表情符号,将您的 application.yaml 文件更新为:
spring:
http:
encoding:
charset: UTF-8
enabled: true
force: true
或者在控制器中将 UTF-8 定义为
HttpHeaders headers = new HttpHeaders();
headers.setContentType("application/json;charset=UTF-8");