赞
踩
前端发送的json格式对象后端不能直接用参数接收,要封装一个接收类
- export async function deleteUser(body: API.deleteid, options?: { [key: string]: any }) {
- return request<API.BaseResponse<boolean>>('/api/user/delete', {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- data: body,
- ...options,
- });
- }
后端接收参数报错
- @PostMapping("/delete")
- BaseResponse<Boolean> deleteUser(@RequestBody long id, HttpServletRequest request){
- boolean b = userService.deleteUser(userDeleteDTO.getId(), request);
- return ResultUtils.success(b);
- }
改为
- @PostMapping("/delete")
- BaseResponse<Boolean> deleteUser(@RequestBody UserDeleteDTO userDeleteDTO, HttpServletRequest request){
- boolean b = userService.deleteUser(userDeleteDTO.getId(), request);
- return ResultUtils.success(b);
- }
- @Data
- public class UserDeleteDTO {
- private long id;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。