Class JstlView

  extended by
      extended by
          extended by org.springframework.web.servlet.view.AbstractView
              extended by org.springframework.web.servlet.view.AbstractUrlBasedView
                  extended by org.springframework.web.servlet.view.InternalResourceView
                      extended by org.springframework.web.servlet.view.JstlView
All Implemented Interfaces:
BeanNameAware, InitializingBean, ApplicationContextAware, View

public class JstlView
extends InternalResourceView

Specialization of InternalResourceView for JSTL pages, i.e. JSP pages that use the JSP Standard Tag Library.

Exposes JSTL-specific request attributes specifying locale and resource bundle for JSTL's formatting and message tags, using Spring's locale and message source.

Typical usage with InternalResourceViewResolver would look as follows, from the perspective of the DispatcherServlet context definition:

 <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
   <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
   <property name="prefix" value="/WEB-INF/jsp/"/>
   <property name="suffix" value=".jsp"/>

 <bean id="messageSource" class="">
   <property name="basename" value="messages"/>
Every view name returned from a handler will be translated to a JSP resource (for example: "myView" -> "/WEB-INF/jsp/myView.jsp"), using this view class to enable explicit JSTL support.

The specified MessageSource loads messages from "" etc files in the class path. This will automatically be exposed to views as JSTL localization context, which the JSTL fmt tags (message etc) will use. Consider using Spring's ReloadableResourceBundleMessageSource instead of the standard ResourceBundleMessageSource for more sophistication. Of course, any other Spring components can share the same MessageSource.

This is a separate class mainly to avoid JSTL dependencies in InternalResourceView itself. JSTL has not been part of standard J2EE up until J2EE 1.4, so we can't assume the JSTL API jar to be available on the class path.

Juergen Hoeller
See Also:
JstlUtils.exposeLocalizationContext(javax.servlet.http.HttpServletRequest, org.springframework.context.MessageSource), InternalResourceViewResolver, ResourceBundleMessageSource, ReloadableResourceBundleMessageSource

Field Summary
Fields inherited from class org.springframework.web.servlet.view.AbstractView
Fields inherited from class
Constructor Summary
Method Summary
protected  void exposeHelpers(HttpServletRequest request)
          Expose helpers unique to each rendering operation.
protected  void initApplicationContext()
          Subclasses can override this for custom initialization behavior.
Methods inherited from class org.springframework.web.servlet.view.InternalResourceView
exposeModelAsRequestAttributes, prepareForRendering, renderMergedOutputModel, useInclude
Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView
afterPropertiesSet, getUrl, setUrl, toString
Methods inherited from class org.springframework.web.servlet.view.AbstractView
addStaticAttribute, createRequestContext, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getStaticAttributes, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setRequestContextAttribute
Methods inherited from class
getServletContext, getTempDir, getWebApplicationContext, isContextRequired
Methods inherited from class
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public JstlView()
Method Detail


protected void initApplicationContext()
Description copied from class: ApplicationObjectSupport
Subclasses can override this for custom initialization behavior. Gets called by setApplicationContext after setting the context instance.

Note: Does not get called on reinitialization of the context but rather just on first initialization of this object's context reference.

initApplicationContext in class ApplicationObjectSupport
See Also:


protected void exposeHelpers(HttpServletRequest request)
                      throws Exception
Description copied from class: InternalResourceView
Expose helpers unique to each rendering operation. This is necessary so that different rendering operations can't overwrite each other's contexts etc.

Called by renderMergedTemplateModel. The default implementation is empty. This method can be overridden to add custom helpers as request attributes.

exposeHelpers in class InternalResourceView
request - current HTTP request
Exception - if there's a fatal error while we're adding attributes
See Also:
InternalResourceView.renderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse), exposeHelpers(javax.servlet.http.HttpServletRequest), TilesJstlView.exposeHelpers(javax.servlet.http.HttpServletRequest)

Copyright (c) 2002-2007 The Spring Framework Project.