相同的配置,springboot 2.0.0 能正常访问到jsp,2.1.3出现not found错误

在升级SpringBoot从2.0.0到2.1.3后,相同配置的项目中,JSP页面无法正常访问,出现'not found'错误。虽然依赖包和2.0.0版本无明显变化,但注意到Spring版本从5.0.4.RELEASE升级到了5.1.5.RELEASE,同时Tomcat版本也从8.5.28变为9.0.16。目前问题原因尚不明确,可能与Spring或Tomcat版本升级有关。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

2.1.3配置如下,启动时,Tomcat没有执行Spring初始化,[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.3.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

	<dependencies>
	   <!-- springboot web组件支持 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        
        <!-- Springboot 外部tomcat支持 -->
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
	</dependencies>

jsp访问错:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sat Apr 13 20:25:10 CST 2019
There was an unexpected error (type=Not Found, status=404).
No message available

后台异常:

019-04-13 20:25:10.454  INFO 9788 --- [nio-8085-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-04-13 20:25:10.454  INFO 9788 --- [nio-8085-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-04-13 20:25:10.465  INFO 9788 --- [nio-8085-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 11 ms
2019-04-13 20:25:10.528  WARN 9788 --- [nio-8085-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : Path with "WEB-INF" or "META-INF": [WEB-INF/pages/test.jsp]

2.0.0 配置依赖包跟上面没有变化,但是JSP访问正常:

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>


原因未知:但是查看了引用包的版本是有差别的,前者spring.version 5.1.5.RELEASE 后者5.0.4.RELEASE,两个版本的TOMCAT包前者是9.0.16后者是8.5.28.

等待以后找到原因补上。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值