springboot 2.0.8 跳转jsp页面
springboot项目创建教程 https://blog.csdn.net/q18771811872/article/details/88126835
springboot 2.0跳转 html教程 https://blog.csdn.net/q18771811872/article/details/88312862
jsp+html跳转整合 https://blog.csdn.net/q18771811872/article/details/88343672
这是一篇单独跳转jsp页面的教程 ,后续会介绍html和jsp同时存在的 我暂时注释了thymeleaf模版以及配置
1创建目录结果和jsp文件

2配置return 返回模版 及代码
@RequestMapping(value = "/testJsp", produces = "application/json;charset=UTF-8", method = {RequestMethod.POST, RequestMethod.GET})
public String testJsp(Model m, HttpServletRequest request, HttpServletResponse response){
List<Map<String,Object>> list=userService.userQueryAll();
request.setAttribute("list",list);
log.info("进入了testJsp方法!");
return "views/testJsp";
}
3.application.yml 文件 配置 thymeleaf 模版参数
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 文件加入tomcat和jsp支持 ,如果是有thymeleaf架包的暂时注释掉,这里只写jsp跳转( 有thymeleaf架包的时候return模版会优先跳转html页面)
<!--tomcat支持-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!--servlet依赖.-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<!--jsp标签库-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
5. jsp页面这里直接用了EL表达式
<%@ 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 + "/";
%>
<!DOCTYPE html >
<html lang="zh-CN">
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script src="<%=basePath%>static/js/jquery-3.3.1.js" charset="utf-8"></script>
</head>
<body>
<table border="1">
<thead>
<tr>
<th>序号</th>
<th>名字</th>
<th>号码</th>
<th>创建时间</th>
</tr>
</thead>
<tbody>
<c:forEach items="${list}" var="listv" varStatus="status">
<tr>
<td>${listv.id}</td>
<td>${listv.name}</td>
<td>${listv.phone}</td>
<td>${listv.create_time}</td>
</tr>
</c:forEach>
</tbody>
</table>
</body>
<script type="text/javascript" charset="utf-8">
</script>
</html>
6. Project Structure里面 这个一般是默认配置好了的,如果没有就要加上哦

就这样启动就行了 效果图如下

原文地址 https://blog.csdn.net/q18771811872/article/details/88342298
springboot 2.0跳转 html教程 https://blog.csdn.net/q18771811872/article/details/88312862
jsp+html跳转整合 https://blog.csdn.net/q18771811872/article/details/88343672
springboot项目创建教程 https://blog.csdn.net/q18771811872/article/details/88126835
springboot 2.0.8 跳转jsp页面的更多相关文章
- springboot 2.0.8 跳转html页面
springboot项目创建链接 https://blog.csdn.net/q18771811872/article/details/88126835 springboot2.0 跳转jsp教程 h ...
- 多模块springboot项目启动访问不了jsp页面
被springboot项目maven打包.启动.访问折腾的头都大了,一步一个坑,在解决了所有的问题之后,那种欣喜若狂的心情只有自己能体会,决定要好好记录一下了,废话不多说了,直接进入正题. 问题和排查 ...
- 分享url带中文参数,打开html操作完毕跳转jsp页面中文乱码解决
1.在app端分享参数组合时不对传递的url进行任何编码. 2.打开html页面时使用 escape函数对有中文的参数进行编码 escape(GetQueryString("paramete ...
- springboot跳转jsp页面
springboot支持jsp页面跳转 官方不推荐jsp的支持(jar包不支持jsp,jsp需要运行在servletContext中,war包需要运行在server服务器中如tomcat)官方推荐使用 ...
- springboot 2.0 整合 同时支持jsp+html跳转
springboot项目创建教程 https://blog.csdn.net/q18771811872/article/details/88126835 springboot2.0 跳转html教程 ...
- springboot 运行jar 跳转jsp页面
pom.xml 添加 <!-- tomcat支持 --> <dependency> <groupId>org.springframework.boot</gr ...
- springboot+jsp+mybatis项目实例(后台成功,但是无法跳转jsp页面,没有实体类的注解,看springboot+jsp第二弹相关配置,即可成功配置jsp)
SpringBoot是用来简化SpringMvc开发的项目,这里自然要整合mybatis等持久化框架! 先看看项目目录: 一.在pom.xml中配置依赖jar包:<project xmlns=& ...
- request.getRequestDispatcher跳转jsp页面失败
我在JS里面写了个Ajax,传值给控制器,然后利用request.getRequestDispatcher(),打算跳转至另外一个页面.但是没有跳转成功,运行之后没反应. 在网上搜了资料发现,利用aj ...
- 18. 进livebos对象直接跳转jsp页面的做法
在网格脚本定义添加: window.onload=function(){ window.location.href='/plug-in/sinopec/contractManagement/h ...
随机推荐
- 有关js的一些小问题
忘了从哪里找来抄下来的: js执行顺序问题 1.函数的声明和调用 “定义式”函数声明 function fn1() {......} "赋值式"函数声明 var f=functio ...
- laravel5.2总结--请求
1 获取请求 1.1 获取请求的 URI 1>path 方法会返回请求的 URI.所以,如果接收到的请求目标是 http://domain.com/foo/bar,那么 path 方法就 ...
- php伪随机数漏洞 以及脚本php_mt_seed的使用教程
前几天在群里看到了一个题目,发现自己没有接触过这个伪随机数这个漏洞,在此记录下. 搜索这两个函数 mt_scrand() mt_rand() mt_scrand(seed)这个函数的意思,是通过分发s ...
- Python-S9-Day124-爬虫&微信
01 今日内容概要 02 内容回顾:flask上下文 03 内容回顾:多app应用 04 内容回顾:面向对象和数据库 05 内容回顾:爬虫 06 Web微信:获取二维码(一) 07 Web微信:获取二 ...
- Linux下librtmp使用及编程实战
最近想做rtmp的推流.直播的小项目,不想直接使用FFmpeg进行推流,FFmpeg进行推流特别简单,因为它已经将编码以及librtmp都集成好了,没啥意思.FFmpeg推流的例子,在雷神的博客里可以 ...
- imx6移植librtmp
一.openssl交叉编译 1.下载 https://www.openssl.org/source/ 版本不要太高,刚开始版本高了,有些函数取消了,链接不上 使用1.0.1f即可 2.编译成共享库 . ...
- Selenium - WebDriver: Locating Elements
Selenium provides the following methods to locate elements in a page: find_element_by_id find_elemen ...
- File IO(NIO.2):什么是路径?
简介 文件系统以某种形式的媒体(通常为一个或多个硬盘驱动器)存储和组织文件,使得它们可以容易地被检索.目前使用的大多数文件系统将文件存储在树形(或分层)结构中.在树的顶部是一个(或多个)根节点.在根节 ...
- 【转】Using Raycasts and Dynamically Generated Geometry to Create a Line of Sight on Unity3D
http://www.linkedin.com/pulse/using-raycasts-dynamically-generated-geometry-create-line-thomas José ...
- [Cocos2dx Bug] [win32] Function CCFileUtils::fullPathFromRelativeFile forget consider the path separated by '\\'
[Cocos2dx 2.2.4] [win32平台Bug] const char* CCFileUtils::fullPathFromRelativeFile(const char *pszFilen ...