This article brings you an introduction to the method of jumping to jsp pages in springboot 2.0.8 (with code). It has certain reference value. Friends in need can refer to it. I hope it will be useful to you. Helps.
This is a tutorial to jump to the jsp page alone. Later, I will introduce the coexistence of html and jsp. I temporarily annotated the thymeleaf template and configuration
1 Create directory results and jsp files
2 Configure return return template and code
@RequestMapping(value = "/testJsp", produces = "application/json;charset=UTF-8", method = {RequestMethod.POST, RequestMethod.GET}) public String testJsp(Model m, HttpServletRequest request, HttpServletResponse response){ List
3.application.yml file configuration thymeleaf template parameters
spring: dataSource: type: com.alibaba.druid.pool.DruidDataSource url: jdbc:mysql://localhost:3306/db-test?useUnicode=true&characterEncoding=utf8&tinyInt1isBit=false&usessl=false username: root password: 123456 driverClassName: com.mysql.jdbc.Driver mvc: view: #新版本 1.3后可以使用 suffix: .jsp prefix: /WEB-INF/ view: #老版本 1.4后被抛弃 suffix: .jsp prefix: /WEB-INF/
4.pom.xml file Add tomcat and jsp support. If there is a thymeleaf rack package, comment it out temporarily. Here only write jsp jump (When there is a thymeleaf rack package, the return template will give priority to jump to the html page)
org.springframework.boot spring-boot-starter-tomcat provided org.apache.tomcat.embed tomcat-embed-jasper provided javax.servlet javax.servlet-api 4.0.1 provided javax.servlet jstl
5. The EL expression is used directly in the jsp page
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" pageEncoding="UTF-8" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %>Title
序号 | 名字 | 号码 | 创建时间 |
---|---|---|---|
${listv.id} | ${listv.name} | ${listv.phone} | ${listv.create_time} |
6. This is usually configured by default in the Project Structure. If not, you need to add it
Just start it like this. The rendering is as follows
The above is the detailed content of Springboot 2.0.8 Introduction to the method of jumping to jsp page (with code). For more information, please follow other related articles on the PHP Chinese website!