当前位置: 首页 > 工具软件 > smart-servlet > 使用案例 >

Could not open ServletContext resource [/WEB-INF/DispatcherServlet-servlet.xml]

公孙胡媚
2023-12-01

解决方案

因为会默认加载[/WEB-INF/DispatcherServlet-servlet.xml]
所以要在web.xml中修改配置
原来的

<servlet>
        <servlet-name>DispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

修改后

<servlet>
        <servlet-name>DispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
<!--            修改配置路径-->
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:applicationContext.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
 类似资料: