controller层代码
@RequestMapping(value = "/deleteone",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
public Result deleteone(@RequestParam(name = "checkitem") String checkItem){
try {
//解决get乱码问题
String str=new String(checkItem.getBytes("ISO8859-1"),"UTF-8");
//将字符串转换成对象
CheckItem checkItem1 = new Gson().fromJson(str, CheckItem.class);
Integer id = checkItem1.getId();
System.out.println(id);
checkItemService.deleteone(id);
return new Result(true, MessageConstant.DELETE_CHECKITEM_SUCCESS,null);
} catch (Exception e) {
e.printStackTrace();
}
return new Result(false, MessageConstant.DELETE_CHECKITEM_FAIL,null);
}
前端js:
handleDelete(row) {
this.resetForm();
//发送ajax请求
var _this = this;
//param由后端QueryPageBean queryPageBean接收请求映射参数
console.log(row)
axios.get("/checkitem/deleteone.do", {params:{checkitem:row}},
).then((resp) => {
console.log(resp.data)
if(resp.data.flag){ // 服务器端处理成功
_this.$message({
message: resp.data.message,
type: 'success'
});
_this.findPage();
}else{ // 服务器端处理失败
_this.$message.error(resp.data.message);
}
});
尝试过后端直接用对象接收数据 发现接收的全是null?
此问题有待解决!上面的方法只是没办法的情况下的办法
|