Announcement Announcement Module
Collapse
No announcement yet.
How to attach DELETE action to a link in records list page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to attach DELETE action to a link in records list page

    I can't figure how to 'attach' DELETE action to a link in records list with Spring MVC. I found no examples nowhere, just some using form like this which does not work either

    Code:
    <c:forEach items="${posts}" var="post"
    <form id="${someFormId}" action="posts/${post.id}" method="delete">
    <input id="id" name="id" type="hidden" value="${post.id}"/>
    </form> </c:foreach>
    
    //in the controller:
    @Controller @RequestMapping("/posts")
    public class PostsController {
    ...
    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
    public String destroy(@PathVariable Long id) {
    Post post = postService.findById(id);
    postService.destroy(post);
    return "redirect:/posts"; } ...
    }
    Any idea? Thnx.
Working...
X