I came to know that Spring RESTFul services can be developed using Spring MVC.
I have a situation where I have Spring webapp and Spring RESTFul service. They both use other modules in common.
Is it possible that I can have Spring webapp contain RESTFul service along with Spring MVC web app?
Do I need to have two DispatcherServlet with different URL pattern?
Definitely, actually I think that would be the preferred route for all web apps. In some cases, people will make their entire Web App be RESTFul.
Anyway, the whole key is that the Controller code should not be "specific" in just Spring MVC or Spring RESTFul. It is both. The Controller code wouldn't change and a method in a controller can handle both a RESTFul and regular request.
I wrote a web app recently, not live, but al I had to do was change the URL by just adding a ".json" to go from a standard web URL request to a RESTFul request for a JSON representation of some data.
So I can have both types of requests go through the controller. Thats really great.
I couldn't understand about the changing the request to .json for sending it to RESTFul method of controller. I understand that you have the JSON representation.
I will have to use the object marshalling due to security reason.
There is a new "view resolver" This is for the new RESTful Web Services, and it can also contain a list of other view resolvers. So you can map by request type, and also extension. So if the URL is say www.mywebsite.com/MyApp/Account/list in the browser, then the returned view string will be used to resolve to say a jsp page. But if the url in the browser is www/mywebsite/MyApp/Account/list.json it will call the exact same Controller method, however the Model that is returned will be sent back as JSON representation instead of going to a jsp page.
When you read about Spring RESTful, you will see what I mean.