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上传递参数的示例?