赞
踩
在使用ajax提交结合@DeleteMapper做删除时,我加上了_method="DELETE",但提交后识别到post请求,网上说时2.4需要加上一句配置
spring.mvc.hiddenmethod.filter.enabled=true
- $.ajax({
- type: 'post',
- url: '/backend/category/' + data.id,
- data: {'_method': 'DELETE'},
- success: function (result) {
- console.log(result)
- if (result.code !== 0) {
- layer.msg(result.message, {shift: 6});
- return false;
- }
- layer.msg(result.message, {icon: 1}, function () {
- location.href = '/backend/category';
- });
- }
- });
- @DeleteMapping("/category/{id}")
- @ResponseBody
- public JsonResponse delete(@PathVariable("id") Long id)
- {
- categoryService.removeById(id);
- return new JsonResponse().message("删除成功").success();
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。