springboot @postmapping参数获取为null
@PostMapping(value = "/save-details")
public RestBean<Void> saveDetails(@RequestAttribute(Const.ATTR_USER_ID) int userId, @RequestBody @Valid DetailsSaveVO vo) {
return accountDetailsService.saveAccountDetails(userId, vo) ? RestBean.success() : RestBean.failure(400, "用户名已占用,请更换!");
}
注意@requestBody导包!要使用springframework而不是swagger!!!
可以正常对数据库操作.
但是输入中文提示`java.sql.SQLException: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='
原因: 因为新创建的表字符集是latin1_swedish_ci,而原有的字符集需要utf8mb4_general_ci,所以报错。
ALTER TABLE 表名 CONVERT TO CHARACTER SET ‘utf8’;
@RequestBody、@RequestParam 、@PathVariable、@RequestPart
https://blog.csdn.net/qq_35341203/article/details/108877579