Announcement Announcement Module
No announcement yet.
how is used in petclinic example? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • how is used in petclinic example?

    Hi there,

    I've just started playing with Spring, and I look into the petclinic example that came as part of the distribution and followed Ken Kreb's write-ups about it on the spring site. I am really impressed with its Business Layer and Hibernate persistance. It is very simple and elegant.

    However, the pure Spring web tier took me a while to understand (or guess, to be exact) how it hooks up. web.xml and petclinic-servlet.xml all seem reasonable to me. I wonder why do we need sure it's one more level of indirection. what's the JstlView for? Does most Spring MVC web app need such a artifect? or can it be achived within petclinic-servlet.xml (or somewhere else)?

    So far, I've read Rod Johnson's Expert One-on-On .. w/o EJB. any good tutorials/books for quickly learn how to use Spring (beside just digging through samples that came with the release)?

    For more active UI experience, I am also looking into JSF (Oracle seems to have a fairly comprehensive platform neutral component suite in EA, MyFaces, OurFaces free components is growing). I am interested in hearing has anyone used Spring/JSF in development/production? Any insight/experience to share? what's the config/package is recomended?


  • #2
    Spring's MVC support is build around Controllers and a ModelAndView class. The ModelAndView class contains either a View object or a logical view name (a String). If the latter is the case, the view name is resolved to a View object using a ViewResolver. I guess Petclinic uses the ResourceBundleViewResolver where the resource bundle ( maps view names to View classes.

    The view class (JstlView for example) is what makes the view concrete. A JstlView maps to a JSP page. VelocityViews map to Velocity templates, etcetera...

    Yes, it's an additional level of indirection, but in most cases you don't really need the ResourceBundleViewResolver, an InternalResourceViewResolver is almost the same, where you configure only one view class...

    JSF integration is there, however not really extensive. There is a VariableResolver, resolver beans from a Spring application context (#{springBeanName.user}) will resolve to appCtx.getBean("springBeanName").getUser().