0
20
18
07
为了账号安全,请及时绑定邮箱和手机立即绑定

spring mvc页面跳转报404

spring mvc页面跳转报404

慕少森 2019-03-22 18:15:03
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 ?????????
查看完整描述

3 回答

?
万千封印

TA贡献1891条经验 获得超3个赞

在web.xml中把url-pattern改成/就行了


<servlet-mapping>

    <servlet-name>dps</servlet-name>

    <url-pattern>/</url-pattern>

</servlet-mapping>


查看完整回答
反对 回复 2019-04-23
?
吃鸡游戏

TA贡献1829条经验 获得超7个赞

web-inf 是不可见的,需要内部跳转,你或者把这个jsp提出来,或者自己在jsp上写一个redirect


查看完整回答
反对 回复 2019-04-23

添加回答

代码语言

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号