Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6723013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:31:02+00:00 2026-05-26T09:31:02+00:00

I am trying to delete an entity on a page via a delete link

  • 0

I am trying to delete an entity on a page via a delete link (a href) or delete button (form). I am using delete button since a link calls for a “GET” instead of a “POST”

This is the JSP code which intends on doing that:

<td><form:form method="DELETE" action="/client/invoices/${invoice.id}"><input type="submit" value="delete"></form:form></td>

The resulting html is this:

<td><form id="command" action="/client/invoices/9" method="post"><input type="hidden" name="_method" value="DELETE"/><input type="submit" value="delete"></form></td>

So, I’m pretty happy. It has _method which indicates that it is a DELETE action. Here is my controller code:

@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
public String delete(@PathVariable("id") Long id, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
        invoiceServiceHibernate.removeInvoice(id);
        return "redirect:/invoices";
}

So, what happens is that this method is not called. I have another method which does a POST to create an invoice and clicking the delete button instead created an invoice. My guess is that the controller looks at the servlet as a POST request and uses the first method which handles a POST request which in this case is to create a new invoice.

I try to make this “RESTful” so I want this to be /invoice/id and using POST, PUT, DELETE, GET but I am not sure how to code that in the controller using Spring MVC.

I am able to get this to work by appending “verbs” such as /invoices/id/delete and setting up the controller as

@RequestMapping(value = "/{id}/delete", method = RequestMethod.POST)

Note, the RequestMethod.POST but since the map values explicitly have /id/delete, it does not use the default POST which is mapped to /invoices and /invoices/id.

I hope I am clear. If anyone have any suggestions or sample code (strongly preffered), I would appreciate it. I’ve read these SO links for references:
Link1
Link2
Link3

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:31:03+00:00Added an answer on May 26, 2026 at 9:31 am

    Did you set the HiddenHttpMethodFilter in your web.xml? That filter converts posted method parameters into HTTP methods and allows support for method conversion in the Spring MVC form tags.

    <filter>
        <filter-name>hiddenHttpMethodFilter</filter-name>
        <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>hiddenHttpMethodFilter</filter-name>
        <servlet-name>servletName</servlet-name>
    </filter-mapping>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using silverlight mvvm light framework. when I was trying to delete entity
I'm trying to delete several working copy directories, but I get an Access Denied
i am trying to delete some files using a batch file.. (winxp) my problem
I'm trying to implement a delayed blog post deletion scheme. So instead of an
I'm trying to delete a record from the GAE datastore via an ajax query
I need help with trying to insert a record using MVC and Entity Framework.
I am using MySQL .net connector 6.4.4.0 and Entity Frame work 4.1 and trying
I am trying to get an insert stored procedure to work on an entity
I'm having a problem trying to delete a POCO object with my Entity Framework
I'm trying to delete using the delete action. But whenever I go click the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.