I'm trying to use a link in my JSP to pass a parameter to a method in my Spring controller, but I get a 404 error. Here is the relevant part of my JSP code.
<c:forEach var="bulletin" items="${bulletins}"> <c:if test="${bulletin.approved}"> <a href="/bulletin/${bulletin.id}" >${bulletin.name} -- ${bulletin.subject}</a> <br /> <br /> </c:if> </c:forEach>
Here is the method in my controller.
@RequestMapping(value = "/bulletin/{id}", method = RequestMethod.GET) public ModelAndView getSingleBulletin(@PathVariable("id") int id, Model model) { ModelAndView mav = new ModelAndView(); try { Bulletin bulletin = bulletinDAO.getSingleBulletin(id); mav.setViewName("WEB-INF/jsp/ShowBulletin"); if (bulletin != null) { ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder .currentRequestAttributes(); HttpSession session = attributes.getRequest().getSession(true); session.setAttribute("bulletin", bulletin); } } catch (Exception e) { System.out.println(e.getMessage()); mav.setViewName("WEB-INF/jsp/FailurePage"); } return mav; }