Search code examples
springjsphttp-status-code-404

Getting 404 error calling another JSP from link


I have a menu in my web page, and I have added a new link is not working. I am getting this error message.

HTTP Status 404 – Not Found

Type Status Report

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Here is the HTML code for the link.

<td><a href="<c:url value="/35yearreunion" />"><img src="images/menu/35-year-reunion.jpg" alt="Memories" /></a></td>

I do have a Spring controller method, and this is it. My web page is named reunion2021.jsp.

@RequestMapping(value = "/35yearreunion")
public String thirtyfiveYearReunion(Model model) {
    return "reunion2021";
}

Solution

  • Try adding the request method to your controller's method , either this way :

    @RequestMapping(value = "/35yearreunion",method = RequestMethod.GET)
    public String thirtyfiveYearReunion(Model model) {
        return "reunion2021";
    }
    

    or this way :

    @GetMapping(value = "/35yearreunion")
    public String thirtyfiveYearReunion(Model model) {
        return "reunion2021";
    }