This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Spring and the fly likes Spring 3 MVC: Controller/Action/Parameters convention? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring 3 MVC: Controller/Action/Parameters convention?" Watch "Spring 3 MVC: Controller/Action/Parameters convention?" New topic
Author

Spring 3 MVC: Controller/Action/Parameters convention?

Jason Ross
Greenhorn

Joined: Mar 12, 2009
Posts: 6
Hi,

I'm new to Spring MVC, and the Spring FW in general. My previous experience is with PHP (Zend FW) and C#/ASP.NET MVC.

I'm used to having this URL mapping convention supported in all of frameworks I've worked in:

http://www.domain.com/myController/action/[optional parameters]

The framework would then look for a class named "MyControllerController," and a method in that controller named "Action" and execute it. For example:



I've seen some examples of controllers and read the Spring documentation. It looks like that convention is not supported in Spring MVC. Am I correct? You have to explicitly declare the mapping in either a bean config file or use a @RequestMapping annotation?
kunalkumar somani
Greenhorn

Joined: Jul 13, 2011
Posts: 7

Hi Jason,

Yes, You are right.

Spring MVC framework is designed around a DispatcherServlet with configurable handler mappings, view resolution ant many things. The default handler is based on the @Controller and @RequestMapping annotations if you are using spring 3.0. In older version of spring you need to declare the bean in configuration file for request mapping.
 
Don't get me started about those stupid light bulbs.
 
subject: Spring 3 MVC: Controller/Action/Parameters convention?
 
Similar Threads
Spring MVC -- where does the model code go?
@Controller annotation query
Getting request object outside of DispatchServlet.
MVC in Swing for a modularised View
Spring - passing values by parametrs to Controller