This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Spring and the fly likes Setting up Spring Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Setting up Spring Servlet" Watch "Setting up Spring Servlet" New topic

Setting up Spring Servlet

Paul Wam

Joined: Apr 05, 2009
Posts: 20
I've successfully edited and deployed Spring's sample application, Petclinic. Petclinic-servlet.xml
uses the beans/spring classes listed below:

My question is how do you know which beans/classes your servlet needs? For example, I'm creating a Spring servlet from scratch - How would I know that Spring needs, for example, the ContentNegotiatingViewResolver configured? What document should I read that would lists all the Spring beans that must be implemented if you want feature x in your servlet?


VenkataPrasad Regula
Ranch Hand

Joined: Jun 30, 2011
Posts: 63
In Spring we do not use Servlets(At least as terminology usage). Spring gives us something called Controller. A Controller = Servlet + Some additional functionalities as jasper report etc. So as you use Controller class you are very much using Servlets. Spring has not deviated itself away from the java Servlet technology. In fact it has used the existing servlet technology and added some more functionalities to it and named it as Controllers. Visit the Controller API and go through the derived subclasses mainly the BaseCommandController and its subclasses and look for examples of these classes on google. For your information we configure Controllers as below
1. Create a Class
2.Make this class as a subclass of one of these controllers(Using extends keyword)
3. Your class inherits some methods from their super classes(Spring Controller classes)
4. Use these methods to code your logic and display the page.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

In current versions of Spring, you don't implement or extend any of Spring's Controller classes or interfaces for your Controllers. The Controller of your will be pojos. You will put Annotations in the class to get the mapping and all the rest.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Setting up Spring Servlet
It's not a secret anymore!