Hi,
Using Spring 2.5.6, Java 1.6 in Jetty 6.21.
applicationContext-mvc.xml (used by web.xml, DispatcherServlet)
My Controller class:Code:<context:component-scan base-package="foo.bar.web"/> <!-- INITIALISE THE ANNOTATED CONTROLLER HANDLERS --> <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
This is the problem:Code:@Controller @RequestMapping("/isp") public class ISPController { @Autowired private ISPService ispService; @RequestMapping(method = RequestMethod.GET) public void index(final Model model) { final List<ISP> isps = ispService.findAll(); model.addAttribute("ISPs", isps); // I have a tiles definition of "isp/index" } @RequestMapping(value="/view", method = RequestMethod.GET) public void view(@RequestParam("id") final Long id, final Model model) { final ISP isp = ispService.find(id); model.addAttribute("ISP", isp); // I have a tiles definition of "isp/view" }
If I try:
http://localhost:8080/isp --> underlying page renders (tiles definition : isp/index)
http://localhost:8080/isp/ --> 404, No Mapping found for HTTP request with URI (/isp/) in DispatcherServlet with name 'dispatcher'
http://localhost:8080/isp/view?id=1 --> 404, No Mapping found for HTTP request with URI (/isp/view) in DispatcherServlet with name 'dispatcher'
I really don't understand why this doesn't work. I thought that all @RequestMappings at method level were relative to the @RequestMapping at the type level. I don't understand why /isp works but /isp/view or /isp/ doesn't.
I have similar methods, i.e., create, delete etc., and if I try to go to http://localhost:8080/isp/create or http://localhost:8080/isp/delete I get the same 404 errors.
I would really appreciate any help that can shed some light on this for me.
Yours most gratefully,
-=bootlaces=-
BTW: I tried removing value="view" from the @RequestMapping for the view method and it didn't work.


Reply With Quote
