1. Configuring the Application.properties File
Open Application.properties Append
spring.mvc.view.prefix=/web-root/
spring.mvc.view.suffix=.jsp
2. Add a jar package that accesses JSP pages in Pom.xml
<!--The following dependent packages required to access the JSP page--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
3. Create a Indexcontrol class
import Org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import Org.springframework.web.bind.annotation.RequestMethod;
@Controller
Public class Indexcontrol {
@RequestMapping (value= "/index", method= Requestmethod. GET)
Public String index () {
return "Index";
}
}
Create the Indexcontrol class under the project's Contrl package
4. Create a JSP file
Create a new index.jsp file and put it in the Src\main\webapp\web-root \ directory without a new directory
5. The access address is as follows:
http://127.0.0.1:8080 or http://localhost:8080/index/can access our home file index.jsp
Spring Boot Learning 02 "How to access the JSP in the Spring Boot project"