Spring Boot项目添加jsp支持
2018-02-28 22:56
591 查看
第一步
修改pom文件,添加如下内容
第二步
修改properties文件,添加如下内容
第三步
添加源代码
jsp文件及其目录结构
action5.jsp
目录结构
最后验证
修改pom文件,添加如下内容
<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>
第二步
修改properties文件,添加如下内容
spring.mvc.view.suffix=.jsp spring.mvc.view.prefix=/WEB-INF/jsp/
第三步
添加源代码
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文件及其目录结构
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> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>action5的视图</title> </head> <body> <img alt="风景" src="<c:url value="/images/desert.jpg"></c:url>"> </body> </html>
目录结构
最后验证
相关文章推荐
- 19. Spring Boot 添加JSP支持【从零开始学Spring Boot】
- 详解SpringBoot 添加对JSP的支持(附常见坑点)
- Spring Boot 学习10--添加JSP支持
- (19)Spring Boot 添加JSP支持【从零开始学Spring Boot】
- SpringBoot学习:添加JSP支持
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- 详解Spring Boot 添加JSP支持
- springboot(九)添加jsp支持
- Spring Boot 添加JSP支持【从零开始学Spring Boot】
- Spring Boot 添加JSP支持【转】
- (19)Spring Boot 添加JSP支持【从零开始学Spring Boot】
- 19. Spring Boot 添加JSP支持【从零开始学Spring Boot】
- spring boot mvc添加对jsp的支持
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- 19. Spring Boot 添加JSP支持【从零开始学Spring Boot】
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- springboot学习(二)springboot项目整合前端,添加jsp的访问
- spring boot 添加jsp支持注意事项
- 使用Spring Boot开发Web项目(二)之添加HTTPS支持
- Spring Boot 添加JSP支持【从零开始学Spring Boot】