我在Spring Boot中使用的是angular,我想使用httpClient将字符串作为Angular中post方法的主体发布:
this.http.post<any>(url, myString);
在API中
@ApiOperation(value = "Saving prefs as string")
@PostMapping(value = "/customer/prefs")
public @ResponseBody ResponseEntity<<?> save(@RequestBody String prefs) {
try {
repository.save(userPrefs);
return new ResponseEntity<>(new JsonMessage("SAVED"), HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>(new JsonError(e), HttpStatus.I_ERROR);
}
}
但是我没有在utf-8中获得prefs编码,我不知道我搞砸了!。