以下是一个简单的Spring Boot应用程序示例,展示如何在其中集成JSP。

1. 创建Spring Boot项目:使用Spring Initializr(https://start.spring.io/)创建一个新的Spring Boot项目,选择Web依赖。

spring boot中使用jsp实例,SpringBoot中使用JSP实例  第1张

2. 添加JSP依赖:在`pom.xml`中添加JSP依赖(如果使用Maven)。

```xml

org.springframework.boot

spring-boot-starter-web

org.apache.tomcat.embed

tomcat-embed-jasper

provided

```

3. 配置`application.properties`:配置JSP相关属性。

```properties

server.port=8080

spring.mvc.view.prefix=/WEB-INF/jsp/

spring.mvc.view.suffix=.jsp

```

4. 创建控制器:创建一个简单的控制器,用于返回JSP页面。

```java

import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.GetMapping;

@Controller

public class MyController {

@GetMapping("