Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Spring
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Paul Clapham
Sheriffs:
paul wheaton
Tim Cooke
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Piet Souris
Bartenders:
Mike London
Forum:
Spring
Getting a 404 error when accessing a Spring controller method via a link
Frank Serkland
Ranch Hand
Posts: 113
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am getting a 404 error when I try to access a method in my controller via a link in a
JSP
. Here is the link.
<a rel="nofollow">${bulletin.name} -- ${bulletin.subject}</a>
Here is the controller method.
@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; }
Frank Serkland
Ranch Hand
Posts: 113
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Problem solved. Here is my URL.
<a href="<c:url value="/bulletin/${bulletin.id}" />" >${bulletin.name} -- ${bulletin.subject}</a>
Here is my controller method.
@RequestMapping(value = "/bulletin/{id}", method = RequestMethod.GET) public String getSingleBulletin(@PathVariable("id") int id, Model model) { try { Bulletin bulletin = bulletinDAO.getSingleBulletin(id); model.addAttribute("bulletin", bulletin); return "ShowBulletin"; } catch (Exception e) { System.out.println(e.getMessage()); return "FailurePage"; } }
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
View resolver is not able to identify the correct view
how to mock return value of method
The requested URL /market/spring/home was not found on this server
Neither BindingResult nor plain target object for bean name 'command' available as request attribute
How do I create a basic confirmation page with dynamic content?
More...