资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Spring打包jar包时jsp页面无法访问怎么办

这篇文章主要讲解了Spring打包jar包时jsp页面无法访问怎么办,内容清晰明了,对此有兴趣的小伙伴可以学习一下,相信大家阅读完之后会有帮助。

我们提供的服务有:成都网站制作、网站建设、微信公众号开发、网站优化、网站认证、延庆ssl等。为成百上千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的延庆网站制作公司

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等其他模块引擎。

看完上述内容,是不是对Spring打包jar包时jsp页面无法访问怎么办有进一步的了解,如果还想学习更多内容,欢迎关注创新互联行业资讯频道。


网站标题:Spring打包jar包时jsp页面无法访问怎么办
链接地址:http://cdkjz.cn/article/gijoes.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220