项目使用的是ssh框架,applicationContext.xml放在/WEB-INF/classes下,web的配置如下:
<servlet>
    <servlet-name>SpringMVCDispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>PageServlet</servlet-name>
<display-name>PageServlet</display-name>
<description></description>
<servlet-class>com.schoolshape.web.servlet.PageServlet</servlet-class>
<load-on-startup>3</load-on-startup>
</servlet>在servlet类有如下代码:
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
System.out.println("webApplicationContext: "+webApplicationContext);通过服务器访问该servlet类会在控制台输出:
webApplicationContext: null
求解?如何才能获得webApplicationContext