In this short video, we leverage the Spring view mechanism to add JSP pages.
There is a lot to say here, but let's start by saying that when a Controller is not annotated with the ResponseBody method, at the method level or at the class level or possibly implicitly with the RestController annotation, the result is the name of a view.
This name is resolved against all view providers. By default, there are only the paths declared by the controllers (I think).
But in application.properties, we define a prefix and suffix to match jsp files located in the src/main/webapp/WEB-INF/jsp/*.jsp.
By convention, the files in WEB-INF are not publicly accessible, but they are internally visible, this is why mypage.jsp is not directly accessible.
But the other paths in src/main/webapp are publicly accessible, this is why we can resolve src/main/webapp/jsp/public.jsp directly.
Usually, Spring controllers pass necessary information to JSP pages so it would not make sense to have them publicly visible.
So this covers the jsp pages and the src/main/resources/application.properties file, although we will possibly need to cover this in more details later.
The only thing left is to add JSP specific dependencies in the POM, namely org.apache.tomcat.embed:tomcat-embed-jasper and javax.servlet:jstl.
And this is how you add JSP to a Spring Boot project.
I think by default, Spring Boot uses an embedded tomcat server, and things would possibly be different if using other servers for serving the content.
Link to demo project: https://github.com/xavierdpt/springbo...