• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

java 搞代码 4年前 (2022-01-05) 18次浏览 已收录 0个评论

这篇文章主要介绍了Spring打包jar包时jsp页面无法访问问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

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

问题如下

当前pom.xml配置

   <!--引入配置文件--> src/main/resourcesfalse<!--引入静态文件--> src/main/webappMETA-INF/resourcesfalse  org.springframework.bootspring-boot-maven-plugin org.apache.maven.pluginsmaven-surefire-plugin true

解决办法:

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

   <!--引入配置文件--> src/main/res<strong style="color:transparent">来源gao@daima#com搞(%代@#码网</strong>ourcesfalse<!--引入静态文件--> src/main/webappMETA-INF/resourcesfalse  org.springframework.bootspring-boot-maven-plugin1.4.2.RELEASE org.apache.maven.pluginsmaven-surefire-plugin true

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

 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页面无法访问问题解决的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Spring打包jar包时jsp页面无法访问问题解决

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址