通过 ServletContext 获取 WebApplicationContext
来源:互联网 发布:天猫淘宝买手机靠谱吗 编辑:程序博客网 时间:2024/05/18 13:27
在视图或者 struts 中通过 ServletContext 获取 WebApplicationContext,三个方法如下,英文很简单我就不用再翻译了:
getRequiredWebApplicationContext
public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc) throws IllegalStateException
Find the root WebApplicationContext for this web application, which is typically loaded viaContextLoaderListener
.Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.
- Parameters:
sc
- ServletContext to find the web application context for- Returns:
- the root WebApplicationContext for this web app
- Throws:
IllegalStateException
- if the root WebApplicationContext could not be found- See Also:
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
getWebApplicationContext
public static WebApplicationContext getWebApplicationContext(ServletContext sc)
Find the root WebApplicationContext for this web application, which is typically loaded viaContextLoaderListener
.Will rethrow an exception that happened on root context startup, to differentiate between a failed context startup and no context at all.
- Parameters:
sc
- ServletContext to find the web application context for- Returns:
- the root WebApplicationContext for this web app, or
null
if none - See Also:
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
getWebApplicationContext
public static WebApplicationContext getWebApplicationContext(ServletContext sc, String attrName)
Find a custom WebApplicationContext for this web application.- Parameters:
sc
- ServletContext to find the web application context forattrName
- the name of the ServletContext attribute to look for- Returns:
- the desired WebApplicationContext for this web app, or
null
if none
0 0
- 通过 ServletContext 获取 WebApplicationContext
- 通过ServletContext取Spring的WebApplicationContext
- Spring 中获取servletContext及WebApplicationContext
- Spring 中获取servletContext及WebApplicationContext
- Spring 中获取servletContext及WebApplicationContext
- Spring 中获取servletContext及WebApplicationContext
- 使用WebApplicationContextUtils.getWebApplicationContext(ServletContext cn)获取WebApplicationContext为null
- webApplicationContext 与servletContext
- webApplicationContext 与servletContext
- webApplicationContext 与servletContext详解
- webApplicationContext 与servletContext
- webApplicationContext 与servletContext
- webApplicationContext 与servletContext
- WebApplicationContext与ServletContext的关系
- Spring 中获取servletContext及WebApplicationContext以及applicationContext三者之间的关系
- 通过ServletContext获取应用级配置参数
- Spring中DispacherServlet、WebApplicationContext、ServletContext的关系
- Spring中DispacherServlet、WebApplicationContext、ServletContext的关系
- storyboard开发,根据系统版本选择不同的storyboard加载
- Maven3安装配置
- POI 导出word
- Wi-Fi(802.11ac)标准优缺点详解
- xCODE 内置的几个工具
- 通过 ServletContext 获取 WebApplicationContext
- Linux Kernel Boot CMDLINE Processing
- (VMware centos) 扩展根目录空间大小
- ffmpeg init_opts()解析
- Oracle常用查看表结构命令
- PowerDesigner反向生成物理数据模型
- 常遇见的警告、错误以及相关解决方法
- 3层路由器与交换机的转发原理
- HTML5 Canvas KineticJS 学习笔记1