If you want to use 1.5.8.RELEASE or similar, then the above example and its explanation are here https://www.surasint.com/spring-boot-jsp/
You just need it in pom.xml
http://maven.apache.org/xsd/maven-4.0.0.xsd "> 4.0.0 org.springframework.boot spring-boot-starter-parent 1.5.8.RELEASE
<groupId>com.surasint.example</groupId> <artifactId>spring-boot-02</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <properties> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.source>1.8</maven.compiler.source> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
And this is in application.properties
spring.mvc.view.prefix: /WEB-INF/jsp/ spring.mvc.view.suffix: .jsp
Then you save your jsp in the folder / WEB -INF / jsp /.
This is the controller.
package com.surasint.example.web.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import java.util.Date; import java.util.Map; @Controller public class TestController { @GetMapping("/testjsp") public String list(Map<String, Object> model) { model.put("this_time",new Date().toString()); return "testjsp-view"; } }
Surasin Tancharoen Dec 13 '17 at 20:26 2017-12-13 20:26
source share