Spring打包jar包后jsp页面访问异常,如何有效排查解决?
- 内容介绍
- 文章标签
- 相关推荐
本文共计659个文字,预计阅读时间需要3分钟。
Spring打包jar包时,JSP页面无法访问,问题如下:
当前pom.xml配置:xml src/main/resources/directory false
问题分析及解决:确保资源目录正确配置,并检查filtering属性是否正确。如果问题依旧,尝试以下步骤:
1. 确认JSP页面路径是否正确。
2.检查web.xml中是否正确配置了JSP页面。
3.确认Tomcat或其他服务器已正确启动。
spring打包jar包时jsp页面无法访问
问题如下
当前pom.xml配置
<build> <resources> <!--引入配置文件--> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> </resource> <!--引入静态文件--> <resource> <directory>src/main/webapp</directory> <targetPath>META-INF/resources</targetPath> <filtering>false</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build>
解决办法:
1.高版本的插件不支持jsp,给spring-boot-maven-plugin指定版本号“1.4.2.RELEASE”
<build> <resources> <!--引入配置文件--> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> </resource> <!--引入静态文件--> <resource> <directory>src/main/webapp</directory> <targetPath>META-INF/resources</targetPath> <filtering>false</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.4.2.RELEASE</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build>
2.根据spring官网说明,可打包war包,仍然可使用jar -jar xxx.war执行。
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.
<packaging>war</packaging>
docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-documentation
spring官方不推荐使用jsp,推荐使用thymeleaf、freemaker、velocity等其他模块引擎。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。
本文共计659个文字,预计阅读时间需要3分钟。
Spring打包jar包时,JSP页面无法访问,问题如下:
当前pom.xml配置:xml src/main/resources/directory false
问题分析及解决:确保资源目录正确配置,并检查filtering属性是否正确。如果问题依旧,尝试以下步骤:
1. 确认JSP页面路径是否正确。
2.检查web.xml中是否正确配置了JSP页面。
3.确认Tomcat或其他服务器已正确启动。
spring打包jar包时jsp页面无法访问
问题如下
当前pom.xml配置
<build> <resources> <!--引入配置文件--> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> </resource> <!--引入静态文件--> <resource> <directory>src/main/webapp</directory> <targetPath>META-INF/resources</targetPath> <filtering>false</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build>
解决办法:
1.高版本的插件不支持jsp,给spring-boot-maven-plugin指定版本号“1.4.2.RELEASE”
<build> <resources> <!--引入配置文件--> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> </resource> <!--引入静态文件--> <resource> <directory>src/main/webapp</directory> <targetPath>META-INF/resources</targetPath> <filtering>false</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.4.2.RELEASE</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build>
2.根据spring官网说明,可打包war包,仍然可使用jar -jar xxx.war执行。
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.
<packaging>war</packaging>
docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-documentation
spring官方不推荐使用jsp,推荐使用thymeleaf、freemaker、velocity等其他模块引擎。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。

