Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc 如何在码头启用PUT方法?_Spring Mvc_Backbone.js_Jetty - Fatal编程技术网

Spring mvc 如何在码头启用PUT方法?

Spring mvc 如何在码头启用PUT方法?,spring-mvc,backbone.js,jetty,Spring Mvc,Backbone.js,Jetty,我正在开发一个SpringREST/主干应用程序 虽然GET工作得很好,但我在PUT方面遇到了麻烦(DELETE可能也是如此) 我的Spring控制器具有以下方法: @RequestMapping(value="/{id}", method = RequestMethod.PUT) public void putItem( @PathVariable("id") String id, @RequestBody Item item) {...} 但是,当我尝试保存主干模型时,会出现以下错误: 4

我正在开发一个SpringREST/主干应用程序

虽然GET工作得很好,但我在PUT方面遇到了麻烦(DELETE可能也是如此)

我的Spring控制器具有以下方法:

@RequestMapping(value="/{id}", method = RequestMethod.PUT)
public void putItem( @PathVariable("id") String id, @RequestBody Item item) {...}
但是,当我尝试保存主干模型时,会出现以下错误:

405 (HTTP method PUT is not supported by this URL)
GET映射位于同一控制器类中,并使用相同的url注释(类级别)

我的注释正确吗?我正在使用Jetty作为服务器,是否需要以某种方式对其进行配置以允许PUT请求

编辑:

假设这是Jetty配置问题,我在webdefault.xml中添加了以下内容

<web-resource-collection>
  <url-pattern>*.do</url-pattern>
  <http-method>GET</http-method>
  <http-method>HEAD</http-method>
  <http-method>PUT</http-method>
  <http-method>POST</http-method>
</web-resource-collection>

*.做
得到
头
放
邮递

定义中。它的效果是现在GET方法返回403(禁止)——因此,这个定义似乎只会约束安全性,而不是使其更自由的方法。我还尝试删除GET和PUT行,但这对我最初的405错误没有任何影响(当然它确实使GET再次工作)

您需要确保在服务器上启用GET POST PUT和DELETE谓词。您的问题不在客户端,因此如果您有权访问服务器设置,请确保启用了上述谓词。我不熟悉jetty,但它看起来好像没有现成的支持,需要某种您自己的处理程序。这是我在快速搜索后找到的资源->

我最终发现问题在于*.do模式


主干在pathvariable之前添加了.do,因此它不起作用。我完全摆脱了后缀,现在它工作了

为什么主干会在任何事情上添加.do?看起来像是定制的