Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.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/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
Html 删除请求方法的springrest_Html_Spring Mvc_Spring Boot - Fatal编程技术网

Html 删除请求方法的springrest

Html 删除请求方法的springrest,html,spring-mvc,spring-boot,Html,Spring Mvc,Spring Boot,我的控制器中有以下方法 @RequestMapping(value = "processPurchase/{poid}", method = RequestMethod.DELETE) public String processOrder(@PathVariable int poid) { // do some processing return acceptPurchaseForm; } 我的HTML <form id="purchase-list-form" clas

我的控制器中有以下方法

@RequestMapping(value = "processPurchase/{poid}", method = RequestMethod.DELETE)
public String processOrder(@PathVariable int poid) {
    // do some processing
    return acceptPurchaseForm;
}
我的HTML

<form id="purchase-list-form" class="form-horizontal" action="/MyNewApp/processPurchase/" method="post">
<input type="hidden" name="_method" value="delete">
<input type="hidden" name="poid" value="">

在上面的情况下,我仍然得到以下错误

WARN:org.springframework.web.servlet.PageNotFound-不支持请求方法“DELETE”


非常感谢您的帮助。

首先,我假设您已经在web.xml中配置了。需要将带有值delete的
\u方法
转换为delete RequestMethod

其次,
poid
正在请求主体中传递,但是在控制器中,您希望它在URL本身中传递。这可能解释了为什么Spring无法映射请求

编辑1:

要在URL中传递
poid
,您必须在生成HTML时在表单中包含操作。这取决于您的视图技术(我使用Freemarker),但您需要执行以下操作:

<form action="/MyNewApp/processPurchase/${poid}" method="post">


假设poid被写入绑定到视图的模型。

首先,我假设您已经在web.xml中配置了。需要将带有值delete的
\u方法
转换为delete RequestMethod

其次,
poid
正在请求主体中传递,但是在控制器中,您希望它在URL本身中传递。这可能解释了为什么Spring无法映射请求

编辑1:

要在URL中传递
poid
,您必须在生成HTML时在表单中包含操作。这取决于您的视图技术(我使用Freemarker),但您需要执行以下操作:

<form action="/MyNewApp/processPurchase/${poid}" method="post">


假设poid已写入绑定到视图的模型。

能否向我展示如何在URL上传递参数的示例?能否向我展示如何在URL上传递参数的示例?