当前位置:   article > 正文

spring boot2.4 @DeleteMapper识别失败

deletemapper

在使用ajax提交结合@DeleteMapper做删除时,我加上了_method="DELETE",但提交后识别到post请求,网上说时2.4需要加上一句配置

spring.mvc.hiddenmethod.filter.enabled=true
  1. $.ajax({
  2. type: 'post',
  3. url: '/backend/category/' + data.id,
  4. data: {'_method': 'DELETE'},
  5. success: function (result) {
  6. console.log(result)
  7. if (result.code !== 0) {
  8. layer.msg(result.message, {shift: 6});
  9. return false;
  10. }
  11. layer.msg(result.message, {icon: 1}, function () {
  12. location.href = '/backend/category';
  13. });
  14. }
  15. });

 

  1. @DeleteMapping("/category/{id}")
  2. @ResponseBody
  3. public JsonResponse delete(@PathVariable("id") Long id)
  4. {
  5. categoryService.removeById(id);
  6. return new JsonResponse().message("删除成功").success();
  7. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/652426
推荐阅读
相关标签
  

闽ICP备14008679号