Use annotation-based controller mappings.
@Controller public class AlertsController { @RequestMapping(value="create", method=RequestMethod.GET) public void create(HttpServletRequest request, Model model) { } }
When accessing alerts/create I get the message Does your handler implement a supported interface like Controller? . This seems strange and contradicts what the documentation says.
So, I add the RequestMapping class to the class:
@Controller @RequestMapping("/alerts") public class AlertsController { @RequestMapping(value="create", method=RequestMethod.GET) public void create(HttpServletRequest request, Model model) { } }
This therefore works. I don't need @RequestMapping , but I do. Now everything is strange. I really wanted to display this in `/ profile / alerts', so I change it to the following:
@Controller @RequestMapping("/profile/alerts") public class AlertsController { @RequestMapping(value="create", method=RequestMethod.GET) public void create(HttpServletRequest request, Model model) { } }
I get 404 when switching to profile/alerts/create , but for some reason it still maps to /alerts/create ?!?!?!
I change it to:
@Controller @RequestMapping("foobar") public class AlertsController { @RequestMapping(value="create", method=RequestMethod.GET) public void create(HttpServletRequest request, Model model) { } }
This is very strange and incredibly inconvenient. Does anyone have a way to fix this or even debug what happens?