Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
向<;添加值时应用程序不工作;上下文参数>;在Spring中的web.xml中使用Maven实现MVC web应用程序_Xml_Spring_Maven_Spring Mvc - Fatal编程技术网

向<;添加值时应用程序不工作;上下文参数>;在Spring中的web.xml中使用Maven实现MVC web应用程序

向<;添加值时应用程序不工作;上下文参数>;在Spring中的web.xml中使用Maven实现MVC web应用程序,xml,spring,maven,spring-mvc,Xml,Spring,Maven,Spring Mvc,我正在使用SpringMVC创建一个web应用程序 在web.xml 然后索引页能够显示,但当我在web.xml中为上下文参数提供值时,索引页不显示 web.xml:-不为上下文参数提供值时 <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/

我正在使用SpringMVC创建一个web应用程序

web.xml 然后索引页能够显示,但当我在web.xml中为上下文参数提供值时,索引页不显示

web.xml:-不为上下文参数提供值时

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
          version="2.5">    

    <display-name>Core Web Application</display-name>

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

    <servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
            <welcome-file>/WEB-INF/pages/index.jsp</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
        </param-value>
    </context-param>

    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
</web-app>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
          http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
          version="2.5">    

    <display-name>Core Web Application</display-name>

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

    <servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
            <welcome-file>/WEB-INF/pages/index.jsp</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
                    /WEB-INF/applicationContext.xml
        </param-value>
    </context-param>

    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
</web-app>

检查日志中的一些异常,并将它们添加到问题中。 SpringMVC还搜索名为“+-servlet”
尝试将
applicationContext.xml
重命名为
mvc dispatcher servlet.xml
,并相应地更改路径和。

您的spring servlet具有“/”的映射
这就是索引页的路径。

嘿,Evgeni,这不是mvc-dispatcher-servlet.xml的问题。根据Spring Mvc约定,Spring框架将查找-servlet.xml。在我的web.xml中,servlet名称是“mvc dispatcher”,在“web-INF”folderOK下有mvc-dispatcher-sevlet.xml。日志中有异常吗?
Please help me to find out the problem.

My Project Structure is as :-
 CoreWebApp
   |_______________ pom.xml
   |
   |_______________ src
   |                 |_____________ main
   |                                 |___________ java
   |                                 |___________ resources
   |                                 |___________ webapp
   |                                                |____ WEB-INF
   |                                                        |_____ applicationContext.xml
   |                                                        |
   |                                                        |_____ mvc-dispatcher-servlet.xml
   |                                                        |
   |                                                        |_____ web.xml
   |                                                        |
   |                                                        |_____ pages
   |                                                                |________ index.jsp
   |
   |______________ target