Friday, March 21, 2014

problem with displaying jsp on spring boot

I'm currently trying to learn Spring Boot (1.0.0 snapshot) in my spare time. I try to use spring-boot-starter-web for building a sample website but had problems when I try to use jsp for the view part of my mvc. Everything was in place.

  • I had a jsp named "welcome-page.jsp" under "src/main/webapp/WEB-INF/jsp/" 
  • In my controller I was sending the user to "welcome-page". 
  • The path configuration was done under application.properties with
    • spring.view.prefix: /WEB-INF/jsp/
    • spring.view.suffix: .jsp


And yet it was not working. Nothing on logs too, even on debug level.
After some search and several trial/errors, I saw that it is impossible to use embedded tomcat for displaying jsps without adding several dependencies to my main pom. Next to the standard spring-boot-starter-web dependency, I had to add jasper and jstl dependencies as well. So long for leaving dependencies to starter templates.


01<dependencies>
02       <dependency>
03           <groupid>org.springframework.boot</groupid>
04           <artifactid>spring-boot-starter-web</artifactid>
05       </dependency>
06       <dependency>
07           <groupid>org.apache.tomcat.embed</groupid>
08           <artifactid>tomcat-embed-jasper</artifactid>
09           <scope>provided</scope>
10       </dependency>
11       <dependency>
12           <groupid>javax.servlet</groupid>
13           <artifactid>jstl</artifactid>
14       </dependency>
15   </dependencies>