As per spring boot documentation, JSP will not work with jar packing with embedded tomcat.
See:
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-web-applications.html#boot-features-jsp-limitations
There some other documentation & sample applications also in boot to instruct to create war file in this scenario.
I think this documentation is wrong, because Servlet 3.0 container will work as long as JSP saved in META-INF/resources folder. I have created a sample application here. (Test is failing due to some reason but application works)
Requesting to update documentation and samples.
I'm not sure that we should encourage people to do this until we've figured out #2451
Is there any update to this issue???
I'm really hoping to use embedded tomcat, but I've got a huge investment in JSPs that I don't want to re-write into thymeleaf so I can use embedded. I know I can just use a WAR file, but part of the coolness of Spring Boot is the ability to go containerless.
thank you.
Using a war file and going containerless are not mutually exclusive. You can use an executable war file (launched with java -jar) and JSPs will work.
I tried the META-INF/resources hack and it seemed to resolve the JSPs, however I get errors with the taglibs:
org.apache.jasper.JasperException: The absolute uri: http://www.springframework.org/tags cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:55) ~[tomcat-embed-jasper-8.0.28.jar!/:8.0.28]
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:277) ~[tomcat-embed-jasper-8.0.28.jar!/:8.0.28]
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:75) ~[tomcat-embed-jasper-8.0.28.jar!/:8.0.28]
at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTldResourcePath(TagLibraryInfoImpl.java:243) ~[tomcat-embed-jasper-8.0.28.jar!/:8.0.28]
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:124) ~[tomcat-embed-jasper-8.0.28.jar!/:8.0.28]
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:416) ~[tomcat-embed-jasper-8.0.28.jar!/:8.0.28]
This is an abuse of META-INF/resources which is intended solely for serving static content. It may not work across all containers. See this thread for details.
<resources>
<!-- 打包时将jsp文件拷贝到META-INF目录下-->
<resource>
<!-- 指定resources插件处理哪个目录下的资源文件 -->
<directory>src/main/webapp</directory>
<!--注意此次必须要放在此目录下才能被访问到-->
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/**</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/**</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
Most helpful comment