getting an warning as“ [org.springframework.web.servlet.PageNotFound] (default task-1) No mapping for GET /ProjectFE/”

≯℡__Kan透↙ 提交于 2019-12-02 11:41:10

First of all arrange your web.xml like this

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" 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">


    <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            WEB-INF/spring-config.xml
        </param-value>
    </context-param>
   <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

As you are defining contex-param you don't need to use init-param same xml file. Now change a little in spring-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc.xsd
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context.xsd">

<mvc:annotation-driven/>

<resources mapping="/resources/**" location="/resources/" />

<beans:bean 
 class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/Views/" />
    <beans:property name="suffix" value=".jsp" />
 </beans:bean>

  <context:component-scan    base-package="controller" />        
 </beans:beans>

Look carefully in line <beans:property name="prefix" value="/Views/" />. Your folder name is Views but you defined view. That's why perhaps you are getting error.

Give a shout if it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!