jsp页面
< % @ page language= "java" contentType= "text/html; charset=utf-8"
pageEncoding= "utf-8" % >
< ! DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
< html>
< head>
< meta http- equiv= "Content-Type" content= "text/html; charset=utf-8" >
< title> Insert title here< / title>
< / head>
< body>
${ msg}
< / body>
< / html>
controller
package com. example. springbootweb. controller;
import org. springframework. stereotype. Controller;
import org. springframework. ui. Model;
import org. springframework. web. bind. annotation. GetMapping;
@Controller
public class JspController {
@GetMapping ( "/helloJsp" )
public String helloJsp ( Model model) {
model. addAttribute ( "msg" , "hello jsp" ) ;
return "index" ;
}
}
pom.xml
< ? xml version= "1.0" encoding= "UTF-8" ? >
< project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns: xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi: schemaLocation= "http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" >
< modelVersion> 4.0 .0 < / modelVersion>
< parent>
< groupId> org. springframework. boot< / groupId>
< artifactId> spring- boot- starter- parent< / artifactId>
< version> 2.2 .4 . RELEASE< / version>
< relativePath/ > < ! -- lookup parent from repository -- >
< / parent>
< groupId> com. example< / groupId>
< artifactId> springboot- web< / artifactId>
< version> 0.0 .1 - SNAPSHOT< / version>
< name> springboot- web< / name>
< description> Demo project for Spring Boot< / description>
< properties>
< java. version> 1.8 < / java. version>
< / properties>
< dependencies>
< dependency>
< groupId> org. springframework. boot< / groupId>
< artifactId> spring- boot- starter- web< / artifactId>
< / dependency>
< dependency>
< groupId> org. springframework. boot< / groupId>
< artifactId> spring- boot- starter- test< / artifactId>
< scope> test< / scope>
< exclusions>
< exclusion>
< groupId> org. junit. vintage< / groupId>
< artifactId> junit- vintage- engine< / artifactId>
< / exclusion>
< / exclusions>
< / dependency>
< ! -- jsp相关-- >
< dependency>
< groupId> org. apache. tomcat. embed< / groupId>
< artifactId> tomcat- embed- jasper< / artifactId>
< / dependency>
< dependency>
< groupId> javax. servlet< / groupId>
< artifactId> javax. servlet- api< / artifactId>
< scope> provided< / scope>
< / dependency>
< dependency>
< groupId> javax. servlet. jsp< / groupId>
< artifactId> javax. servlet. jsp- api< / artifactId>
< scope> provided< / scope>
< / dependency>
< dependency>
< groupId> javax. servlet. jsp. jstl< / groupId>
< artifactId> javax. servlet. jsp. jstl- api< / artifactId>
< / dependency>
< / dependencies>
< build>
< plugins>
< plugin>
< groupId> org. springframework. boot< / groupId>
< artifactId> spring- boot- maven- plugin< / artifactId>
< / plugin>
< / plugins>
< / build>
< / project>