• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Setting up Spring Servlet

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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


 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic