Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting up Spring Servlet

 
Paul Wam
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic