org.apache.ibatis.binding.BindingException: Mapper method 'com.panda.ums.mapper.DeviceInfoMapper.deleteUserInfoByIdAndName' has an unsupported return type: class com.panda.ums.model.UserInfo @DeleteMapping("/delete") public UserInfo deleteDeviceInfo(@RequestParam Integer id,@RequestParam String name) throws Exception { // 修改方法名和参数 return deviceService.deleteUserInfoByIdAndName(id, name); // 调用service的删除方法 } @Override public UserInfo deleteUserInfoByIdAndName(@RequestParam Integer id,@RequestParam String name) throws Exception { System.out.println("id="+id); System.out.println("name="+name); return deviceInfoMapper.deleteUserInfoByIdAndName(id, name); }
时间: 2024-02-24 22:59:05 浏览: 100
根据你提供的代码,我发现问题出在你的`deleteDeviceInfo`方法中。这个方法的返回类型是`UserInfo`,但是它调用了`deviceService.deleteUserInfoByIdAndName`方法,并将这个方法的返回值直接返回给了客户端。而`deviceService.deleteUserInfoByIdAndName`方法的返回值是`deviceInfoMapper.deleteUserInfoByIdAndName`方法的返回值,也就是一个`UserInfo`对象,这个对象不能直接作为`deleteDeviceInfo`方法的返回值。
正确的做法是将`deleteDeviceInfo`方法的返回类型修改为`void`,因为客户端不需要从这个方法中获取任何数据。`deleteDeviceInfo`方法应该只是调用`deviceService.deleteUserInfoByIdAndName`方法,完成数据的删除操作。如果有异常发生,可以将异常抛出,让框架进行异常处理。
修改后的代码如下:
```
@DeleteMapping("/delete")
public void deleteDeviceInfo(@RequestParam Integer id,@RequestParam String name) throws Exception {
deviceService.deleteUserInfoByIdAndName(id, name);
}
```
```
@Override
public void deleteUserInfoByIdAndName(@RequestParam Integer id,@RequestParam String name) throws Exception {
System.out.println("id="+id);
System.out.println("name="+name);
deviceInfoMapper.deleteUserInfoByIdAndName(id, name);
}
```
阅读全文