aspose file tools*
The moose likes Spring and the fly likes What is the difference between using @RequestMapping before class and before  method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "What is the difference between using @RequestMapping before class and before  method " Watch "What is the difference between using @RequestMapping before class and before  method " New topic
Author

What is the difference between using @RequestMapping before class and before method

Abhra Kar
Ranch Hand

Joined: May 22, 2008
Posts: 122
What is the difference between these two---

@Controller
public class HomeController {

@RequestMapping("/home")
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
......................................................................................................
......................................................................................................
}
}


and

@Controller
@RequestMapping("/home.htm")
public class HomeController {
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
......................................................................................................
......................................................................................................
}
}


If we want to call a controller against home.html(properly defined in dispatcher-servlet.xml) can we use any one of this interchangeably


waiting for reply
please help
thanks in advance
Boris Romashov
Ranch Hand

Joined: Feb 23, 2009
Posts: 38
@RequestMapping on class makes that URL to be base for all @RequestMapping on methods.
Abhra Kar
Ranch Hand

Joined: May 22, 2008
Posts: 122
Thanks a lot for the help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is the difference between using @RequestMapping before class and before method