spring mvc页面跳转报404

spring-mvc拦截器


<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

       xmlns:mvc="http://www.springframework.org/schema/mvc"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xmlns:context="http://www.springframework.org/schema/context"

       xsi:schemaLocation="http://www.springframework.org/schema/beans

        http://www.springframework.org/schema/beans/spring-beans.xsd

        http://www.springframework.org/schema/mvc

        http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">


    <!--// 不是用默认过滤规则(指定包内全部扫描), 手动设置规则,只扫描@Controller注解的类。-->

    <context:component-scan base-package="com.prs.dps" use-default-filters="false">

        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>

    </context:component-scan>


    <!--启用 MVC注解(@Controller,@RequestMapping)实现URL映射-->

    <mvc:annotation-driven/>




    <bean id="viewResolver"

          class="org.springframework.web.servlet.view.InternalResourceViewResolver" >

        <property name="prefix" value="/WEB-INF/views/"/>

        <property name="suffix" value=".jsp"/>

    </bean>


程序启动后日志:

23-Jul-2016 14:05:35.050 WARNING [http-apr-8080-exec-2] org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/dps/WEB-INF/views/index.jsp] in DispatcherServlet with name 'dps'

23-Jul-2016 14:05:37.841 WARNING [http-apr-8080-exec-7] org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/dps/WEB-INF/views/index.jsp] in DispatcherServlet with name 'dps'


web根目录变成了/dps/WEB-INF而不是/WEB-INF ?????????

https://img4.mukewang.com/5cbe7e630001c6c106090479.jpg

https://img.mukewang.com/5cbe7e6400016ce508000499.jpg

https://img.mukewang.com/5cbe7e650001e8df08000364.jpg


慕少森
浏览 952回答 3
3回答

万千封印

在web.xml中把url-pattern改成/就行了<servlet-mapping>&nbsp; &nbsp; <servlet-name>dps</servlet-name>&nbsp; &nbsp; <url-pattern>/</url-pattern></servlet-mapping>

吃鸡游戏

web-inf 是不可见的,需要内部跳转,你或者把这个jsp提出来,或者自己在jsp上写一个redirect
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java