栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Spring打包jar包时jsp页面无法访问问题解决

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Spring打包jar包时jsp页面无法访问问题解决

spring打包jar包时jsp页面无法访问

问题如下

当前pom.xml配置


    
      
      
 src/main/resources
 false
      
      
      
 src/main/webapp
 meta-INF/resources
 false
      
    

    
      
 org.springframework.boot
 spring-boot-maven-plugin
 
      
       
 org.apache.maven.plugins 
 maven-surefire-plugin 
  
   true 
  
      
    
  

解决办法:

1.高版本的插件不支持jsp,给spring-boot-maven-plugin指定版本号“1.4.2.RELEASE”


    
      
      
 src/main/resources
 false
      
      
      
 src/main/webapp
 meta-INF/resources
 false
      
    

    
      
 org.springframework.boot
 spring-boot-maven-plugin
 1.4.2.RELEASE
      
       
 org.apache.maven.plugins 
 maven-surefire-plugin 
  
   true 
  
      
    
  

2.根据spring官网说明,可打包war包,仍然可使用jar -jar xxx.war执行。

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-jsp-limitations

JSP Limitations
When running a Spring Boot application that uses an embedded servlet container (and is packaged as an executable archive), there are some limitations in the JSP support.

With Jetty and Tomcat, it should work if you use war packaging. An executable war will work when launched with java -jar, and will also be deployable to any standard container. JSPs are not supported when using an executable jar.

Undertow does not support JSPs.

Creating a custom error.jsp page does not override the default view for error handling. Custom error pages should be used instead.

war

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-documentation

spring官方不推荐使用jsp,推荐使用thymeleaf、freemaker、velocity等其他模块引擎。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/134094.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号