I am trying to use jsp in my project, but it is difficult. I put these two dependencies in the pom.xml
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- If you want to use JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
Then I put these two lines in the aplication.properties
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
I created a page with the name "index.jsp" and put that
<h1>
INDEX
</h1>
<p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Aspernatur nam, nisi, repudiandae illum
ab a aut maxime deleniti voluptas praesentium dicta delectus. Voluptatibus consequuntur
necessitatibus hic eum suscipit, sequi autem.
</p>
And my controller:
package com.example.curso.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class IndexController {
@GetMapping("/")
public String index() {
return "index";
}
}
