Two Laptop Bag*
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 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Setting up Spring Servlet" Watch "Setting up Spring Servlet" New topic
Author

Setting up Spring Servlet

Paul Wam
Greenhorn

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?

org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
org.springframework.web.servlet.handler.SimpleMappingExceptionResolver
org.springframework.web.servlet.view.ContentNegotiatingViewResolver
org.springframework.web.servlet.view.BeanNameViewResolver
org.springframework.web.servlet.view.InternalResourceViewResolver
org.springframework.samples.petclinic.web.VisitsAtomView
org.springframework.web.servlet.view.xml.MarshallingView


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
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting up Spring Servlet
 
Similar Threads
Spring DAO + Hibernate; is this right?
need help in spring security process
using primitives in spring binding
j2ee without ejb
Spring context files