0

EDITED: I forgot the following line in my jsp page :| <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> And this was tha issue

I have an issue with my little application.

I have the following jsp code

<c:forEach items="${movieList}" var="movie">
            <tr>
                <td>${movie.name}</td>
                <td>${movie.genre}</td>
                <td>
                    <form:form method="DELETE" action="/movie/${movie.id}" modelAttribute="movie">
                        <input type="submit" value="DELETE"/>
                    </form:form>
                </td>
            </tr>
        </c:forEach>

And I have the following method in my controller:

@RequestMapping(value = "/movie/{id}", method = RequestMethod.DELETE)
public ModelAndView deleteMovie(Model model, @PathVariable("id") long id, Movie movie) {
    log.info("I am in delete controller()");
    if(movieDao.exists(id)) {
        movieDao.delete(id);
        model.addAttribute("id", movie.getId());
        model.addAttribute("name", movie.getName());
        model.addAttribute("genre", movie.getGenre());
        return new ModelAndView("doneDeleting");
    } else {
        return new ModelAndView("error");
    }
}

If anyone can help me, because it seems to not work when I click on that DELETE button, since that controller is working from POSTMAN. Many thanks.

  • Is there a DELETE request to the server? You can spot it in your browser developer console (on Network tab for Chrome, for example). – Roman Puchkovskiy Mar 26 '17 at 17:54
  • There is no DELETE request in browser – user3698856 Mar 26 '17 at 22:40
  • 2
    According to this http://stackoverflow.com/questions/165779/are-the-put-delete-head-etc-methods-available-in-most-web-browsers DELETE method is not supported directly for FORM submission, but it is supported for Ajax requests. So if `` renders to usual `
    ` tag, it will not work with DELETE method.
    – Roman Puchkovskiy Mar 27 '17 at 09:42

0 Answers0