Reputation:
I'm trying to understand Spring MVC annotations. I've looked at various tutorials, and I just want to make sure I understand. In this example,
@RequestMapping("/welcome")
am I correct in understanding that welcome is the page making the request to the controller, and not the page the controller sends the response to?
Upvotes: 0
Views: 632
Reputation: 6292
If I understand your phrasing correctly, you are right. The @RequestMapping
annotation specifies a URL for which the controller will be invoked to generate page content. @RequestMapping("/welcome")
means that when a browser requests http://yoursite.com/welcome
this controller will be invoked. The annotation does not specify the name of the view you use to render the page output, so you're free to make the controller construct its response using home.jsp
or index.jsp
or any other page you want; you do not need to have a view named "welcome." I'm not sure it really makes sense to say that the controller "sends the response to a page," though, because in HTTP the response to a request is a page; the basic idea of a controller is that given a request, it generates a web page to send back to the client as a response.
Upvotes: 1