类 JstlView
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.BeanNameAware,cn.taketoday.beans.factory.InitializingBean,cn.taketoday.context.ApplicationContextAware,ServletContextAware,View
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 Framework's locale and MessageSource.
Typical usage with InternalResourceViewResolver would look as follows,
from the perspective of the DispatcherServlet context definition:
<bean id="viewResolver" class="cn.taketoday.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="cn.taketoday.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean id="messageSource" class="cn.taketoday.context.support.ResourceBundleMessageSource"> <property name="basename" value="messages"/> </bean>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 "messages.properties" 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 Framework's ReloadableResourceBundleMessageSource instead of the standard ResourceBundleMessageSource for more sophistication. Of course, any other Framework 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.
Hint: Set the AbstractView.setExposeContextBeansAsAttributes(boolean) flag to "true"
in order to make all Framework beans in the application context accessible
within JSTL expressions (e.g. in a c:out value expression).
This will also make all such beans accessible in plain ${...}
expressions in a JSP 2.0 page.
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller
- 另请参阅:
-
JstlUtils.exposeLocalizationContext(cn.taketoday.web.RequestContext, jakarta.servlet.http.HttpServletRequest, cn.taketoday.context.MessageSource)InternalResourceViewResolverResourceBundleMessageSourceReloadableResourceBundleMessageSource
-
字段概要
字段从类继承的字段 cn.taketoday.web.view.AbstractView
DEFAULT_CONTENT_TYPE从类继承的字段 cn.taketoday.context.support.ApplicationObjectSupport
applicationContext, log, messageSourceAccessor从接口继承的字段 cn.taketoday.web.view.View
RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voidexposeHelpers(HttpServletRequest servletRequest, RequestContext request) Exposes a JSTL LocalizationContext for Framework's locale and MessageSource.protected voidinitServletContext(ServletContext servletContext) Wraps the MessageSource with a JSTL-aware MessageSource that is aware of JSTL'sjakarta.servlet.jsp.jstl.fmt.localizationContextcontext-param.从类继承的方法 cn.taketoday.web.servlet.view.InternalResourceView
getRequestDispatcher, getServletContext, isContextRequired, prepareForRendering, renderMergedOutputModel, setAlwaysInclude, setPreventDispatchLoop, setServletContext, useInclude从类继承的方法 cn.taketoday.web.view.AbstractUrlBasedView
afterPropertiesSet, checkResource, getUrl, isUrlRequired, setUrl, toString从类继承的方法 cn.taketoday.web.view.AbstractView
addStaticAttribute, createMergedOutputModel, createTemporaryOutputStream, exposeModelAsRequestAttributes, formatViewName, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestContextToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposeOutputRedirectModel, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponse从类继承的方法 cn.taketoday.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext, unwrapContext, unwrapFactory
-
字段详细资料
-
messageSource
@Nullable private cn.taketoday.context.MessageSource messageSource
-
-
构造器详细资料
-
JstlView
public JstlView()Constructor for use as a bean. -
JstlView
Create a new JstlView with the given URL.- 参数:
url- the URL to forward to
-
JstlView
Create a new JstlView with the given URL.- 参数:
url- the URL to forward tomessageSource- the MessageSource to expose to JSTL tags (will be wrapped with a JSTL-aware MessageSource that is aware of JSTL'sjakarta.servlet.jsp.jstl.fmt.localizationContextcontext-param)- 另请参阅:
-
-
方法详细资料
-
initServletContext
Wraps the MessageSource with a JSTL-aware MessageSource that is aware of JSTL'sjakarta.servlet.jsp.jstl.fmt.localizationContextcontext-param. -
exposeHelpers
protected void exposeHelpers(HttpServletRequest servletRequest, RequestContext request) throws Exception Exposes a JSTL LocalizationContext for Framework's locale and MessageSource.- 覆盖:
exposeHelpers在类中InternalResourceViewrequest- current HTTP request- 抛出:
Exception- if there's a fatal error while we're adding attributes- 另请参阅:
-