0 Replies - 1095 Views - Last Post: 11 April 2013 - 08:27 PM

#1 FHSerkland   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-April 13

Spring 3.2 -- 404 error calling a controller method from a JSP link

Posted 11 April 2013 - 08:27 PM

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. This code appears to match up with what's in the Spring documentation, so I'm confused. 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;
}


Is This A Good Question/Topic? 0
  • +

Page 1 of 1