如何在Spring中创建ServletContext

如何在Spring中创建ServletContext,spring,Spring,我想向servletcontext添加一些值,但不确定如何在spring中获取该对象。任何人都可以帮忙吗试试这个: @Autowired ServletContext servletContext; 看 实现ServletContextAware接口将使Spring能够注入上下文 @Controller public class ServicesImpl implements Services, ServletContextAware{ private ServletContext con

我想向servletcontext添加一些值,但不确定如何在spring中获取该对象。任何人都可以帮忙吗

试试这个:

@Autowired
ServletContext servletContext;

实现ServletContextAware接口将使Spring能够注入上下文

@Controller
public class ServicesImpl implements Services, ServletContextAware{


private ServletContext context;

public void setServletContext(ServletContext servletContext) {
     this.context = servletContext;
}

那没用。。。你能给我一些示例代码吗。