更新时间:2022-06-12 00:26:45
如果您只需要在一个地方进行这种行为,您可以使用标准 Java URLEncoder 位于控制器主体内部:
If you need this behavior only in a single place, you can encode the parameter back to the original form using the standard Java URLEncoder inside of the controller body:
@RequestMapping("/test")
public ResponseEntity<String> test(@RequestParam final String test) {
String encodedParam = URLEncoder.encode(test, "UTF-8");
return ResponseEntity.ok("Requested: " + encodedParam);
}