类 ServletContextAttributeExporter
- java.lang.Object
- org.springframework.web.context.support.ServletContextAttributeExporter
- 所有已实现的接口:
Aware
,ServletContextAware
public class ServletContextAttributeExporter extends Object implements ServletContextAware
Exporter that takes Spring-defined objects and exposes them as ServletContext attributes. Usually, bean references will be used to export Spring-defined beans as ServletContext attributes.Useful to make Spring-defined beans available to code that is not aware of Spring at all, but rather just of the Servlet API. Client code can then use plain ServletContext attribute lookups to access those objects, despite them being defined in a Spring application context.
Alternatively, consider using the WebApplicationContextUtils class to access Spring-defined beans via the WebApplicationContext interface. This makes client code aware of Spring API, of course.
- 从以下版本开始:
- 1.1.4
- 作者:
- Juergen Hoeller
- 另请参阅:
ServletContext.getAttribute(java.lang.String)
,WebApplicationContextUtils.getWebApplicationContext(javax.servlet.ServletContext)
构造器概要
构造器 构造器 说明 ServletContextAttributeExporter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
setAttributes(Map<String,Object> attributes)
Set the ServletContext attributes to expose as key-value pairs.void
setServletContext(ServletContext servletContext)
Set theServletContext
that this object runs in.
构造器详细资料
ServletContextAttributeExporter
public ServletContextAttributeExporter()
方法详细资料
setAttributes
public void setAttributes(Map<String,Object> attributes)
Set the ServletContext attributes to expose as key-value pairs. Each key will be considered a ServletContext attributes key, and each value will be used as corresponding attribute value.Usually, you will use bean references for the values, to export Spring-defined beans as ServletContext attributes. Of course, it is also possible to define plain values to export.
setServletContext
public void setServletContext(ServletContext servletContext)
从接口复制的说明:ServletContextAware
Set theServletContext
that this object runs in.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSet
or a custom init-method. Invoked after ApplicationContextAware'ssetApplicationContext
.- 指定者:
setServletContext
在接口中ServletContextAware
- 参数:
servletContext
- ServletContext object to be used by this object- 另请参阅:
InitializingBean.afterPropertiesSet()
,ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)