This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring 3 MVC: Controller/Action/Parameters convention?" Watch "Spring 3 MVC: Controller/Action/Parameters convention?" New topic

Spring 3 MVC: Controller/Action/Parameters convention?

Jason Ross

Joined: Mar 12, 2009
Posts: 6

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:[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

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.
It is sorta covered in the JavaRanch Style Guide.
subject: Spring 3 MVC: Controller/Action/Parameters convention?
It's not a secret anymore!