First step
Modify the Pom file and add the following
<dependency>
<groupId>javax.servlet</groupId>
<artifactid>jstl</artifactid >
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
< /dependency>
Second Step
Modify the properties file and add the following
spring.mvc.view.suffix=.jsp
spring.mvc.view.prefix=/web-inf/jsp/
Third Step
Adding source code
Package Com.yq.demo.controller;
Import Org.springframework.stereotype.Controller;
Import Org.springframework.ui.Model;
Import org.springframework.web.bind.annotation.RequestMapping;
@Controller public
class Jspcontroller {
@RequestMapping ("/action5") public
String Action05 (model model) {
Model.addattribute ("message", "001");
return "Action5";
}
JSP file and its directory structure
action5.jsp
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%> <%@ taglib prefix="
C "uri=" Http://java.sun.com/jsp/jstl/core "% >
<! DOCTYPE html>
Directory structure
Last validation