java删除用户404错误!!神奇!增改查都没问题啊!!

依据springboot搭建的环境

clipboard.png

clipboard.png

clipboard.png

clipboard.png

点击后面的叉号出现如下错误,
clipboard.png

id保证是正确的,方法也测过没问题的..
修改和新增功能是可以正常使用的。
只有删除会报error,走向js中的错误分支

阅读 2k
2 个回答

一、先把前后端http method统一改为post试下;
二、以下摘自spring官方文档,希望对你有帮助

HTTP method conversion
A key principle of REST is the use of the Uniform Interface. This means that all resources (URLs) can be manipulated using the same four HTTP methods: GET, PUT, POST, and DELETE. For each method, the HTTP specification defines the exact semantics. For instance, a GET should always be a safe operation, meaning that it has no side effects, and a PUT or DELETE should be idempotent, meaning that you can repeat these operations over and over again, but the end result should be the same. While HTTP defines these four methods, HTML only supports two: GET and POST. Fortunately, there are two possible workarounds: you can either use JavaScript to do your PUT or DELETE, or simply do a POST with the 'real' method as an additional parameter (modeled as a hidden input field in an HTML form). This latter trick is what Spring’s HiddenHttpMethodFilter does. This filter is a plain Servlet Filter and therefore it can be used in combination with any web framework (not just Spring MVC). Simply add this filter to your web.xml, and a POST with a hidden _method parameter will be converted into the corresponding HTTP method request.

(译)HTTP方法转换
REST的一个关键原则是使用统一接口。这意味着可以使用相同的四种HTTP方法操作所有资源(URL):GET,PUT,POST和DELETE。对于每个方法,HTTP规范定义了确切的语义。例如,GET应始终是一个安全的操作,这意味着它没有副作用,PUT或DELETE应该是幂等的,这意味着你可以一遍又一遍地重复这些操作,但最终结果应该是相同的。虽然HTTP定义了这四种方法,但HTML只支持两种:GET和POST。幸运的是,有两种可能的解决方法:您可以使用JavaScript来执行PUT或DELETE,或者只使用“real”方法作为附加参数进行POST(在HTML表单中建模为隐藏输入字段)。后一个技巧是Spring的HiddenHttpMethodFilter所做的。这个过滤器是一个普通的Servlet过滤器,因此它可以与任何Web框架(不仅仅是Spring MVC)结合使用。只需将此过滤器添加到web.xml,带有隐藏_method参数的POST将转换为相应的HTTP方法请求。

你好,你不用ajax,试着使用postMan测试一下,用post方式,是不是因为跨域问题导致
还有你可以将你的controller调用的方法代码,还有你的浏览器响应体发出来看看

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题