在Controller中需要有参数
如:
public void testController(HttpServletRequest request){
//Spring上下文
WebApplicationContext ac1= WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
//springMVC上下文
WebApplicationContext ac2 = RequestContextUtils.getWebApplicationContext(request);
}
对比一下struts2 对上下文的获取;
http://blog.csdn.net/lxl_family/article/details/12715337