Spring REST for DELETE Request Method

前端 未结 1 1649
南方客
南方客 2020-12-22 02:38

I have the following method in my controller

@RequestMapping(value = \"processPurchase/{poid}\", method = RequestMethod.DELETE)
public String processOrder(@P         


        
相关标签:
1条回答
  • 2020-12-22 03:29

    First of all, I assume you have the HiddenHttpMethodFilter configured in your web.xml. It is required to convert your _method with value delete to the DELETE RequestMethod

    Secondly, the poid is being passed in the body of the request but in your controller, you are expecting it to be passed in the URL itself. This might explain why Spring is unable to map the request.

    EDIT 1:

    To pass poid in URL, you will have to include in your form action when your HTML is generated. It depends on your view technology (I use Freemarker) but you would be required to do something like this:

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

    Assuming that the poid is written to the model that is binded to your view.

    0 讨论(0)
提交回复
热议问题