Can Anyone can advice me routing mechanism in spring.
I use thymeleaf for my view and I would like to use class names and method names for my url in views- just like in playframework.
But I like in spring that I define url before the controller method declaration.
Whaitting for Your sugestion. Thanks.
Since version 4.1, Spring Framework provides a way to generate routes to resources from templates (i.e. reverse routing in views).
You can check the reference documentation on the subject, but it's basically using auto-generated named routes for that.
I don't know if Thymeleaf supports this in its standard dialect, but you could quite easily extend it; if not, this is probably a feature that could be contributed to the Thymeleaf project.
Let's say you have a MyUserController like this:
With such a dialect, you could then refer to an action like this:
This is the general flow in spring framework.
Whenever user makes a request, it will first go to Spring's DispatcherServlet. The DispatcherServlet job is to send the request to spring mvc controller (custom controller)
You can define your custom controller like this:
Controller: (code snippet)
In servlet- context file , mention the directory/package path of your controller.
Example:
<context:component-scan base-package="nl.springexamples.mvc"/>
In the above controller, it is returning string 'test' which is name of the view file(usually, it will be jsp).
JSP File: test.jsp
Example: How to define internalViewResolver is as shown below
I think, that's pretty much about spring mvc and it's routing flow. I hope it helped you.