提交 | 用户 | age
|
a6a76f
|
1 |
package com.yc.factory; |
F |
2 |
|
|
3 |
import javax.servlet.http.HttpServlet; |
|
4 |
|
|
5 |
import org.springframework.web.context.WebApplicationContext; |
|
6 |
import org.springframework.web.context.support.WebApplicationContextUtils; |
|
7 |
|
|
8 |
/** |
|
9 |
* 取得spring管理的WebApplicationContext |
|
10 |
* @author 邓文峰 2010-2-24 |
|
11 |
* */ |
|
12 |
public class InitBean extends HttpServlet { |
|
13 |
private static final long serialVersionUID = 1L; |
|
14 |
|
|
15 |
private static String contextAbsolutePath; |
|
16 |
|
|
17 |
public void init() { |
|
18 |
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); |
|
19 |
FactoryBean.setCtx(wac); |
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
contextAbsolutePath = getServletContext().getRealPath("/")+"/"; |
|
24 |
} |
|
25 |
|
|
26 |
public static String getContextAbsolutePath(){ |
|
27 |
return contextAbsolutePath; |
|
28 |
} |
|
29 |
} |