Spring Boot Learning 02 "How to access the JSP in the Spring Boot project"

Source: Internet
Author: User

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"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.