本文共 2148 字,大约阅读时间需要 7 分钟。
1.Spring Boot整合Web开发之如何集成JSP?
步骤一:首先添加web和JSP依赖
org.springframework.boot spring-boot-starter-web org.apache.tomcat.embed tomcat-embed-jasper provided
步骤二:更改在src/main/resources下的application.properties配置文件
spring.thymeleaf.cache=falsespring.mvc.view.prefix=/WEB-INF/views/spring.mvc.view.suffix=.jsp
步骤三:在src/main/webapp/WEB-INF/views下创建newJsp.jsp页面
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>Insert title here This is a JSP page!${
wel }
步骤四:创建JSPController
package com.springboot.SpringBootProject.jsp;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;@Controller@RequestMapping("j")public class JSPController { @RequestMapping("show") public String show(Model model) { model.addAttribute("wel", "Welcome to my jsp website!"); return "newJsp"; }}
步骤五:
pom.xml
4.0.0 org.springframework.boot spring-boot-starter-parent 2.2.5.RELEASE com.springboot SpringBootProject 0.0.1-SNAPSHOT SpringBootProject Demo project for Spring Boot 13 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.junit.vintage junit-vintage-engine org.apache.tomcat.embed tomcat-embed-jasper provided org.springframework.boot spring-boot-maven-plugin
转载地址:http://arzqf.baihongyu.com/