项目代码下载:https://files.cnblogs.com/files/xiandedanteng/gatling20200429-1.zip

需求:从后台DB取出雇员数据,显示在前台页面上:

实现步骤

1.添加thymeleaf依赖。看到thymeleaf你是否记起它出现在那首著名的斯卡波罗菜市场呢?

<!-- thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

2.书写控制器

package com.ufo.gatling.ctrl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView; import com.ufo.gatling.entity.Emp;
import com.ufo.gatling.mapper.EmpMapper; @Controller
public class MvcCtrl {
@Autowired
private EmpMapper empMapper=null; // http://localhost:8080/listemps
@GetMapping("/listemps")
public ModelAndView index() {
List<Emp> list=empMapper.findAll(); ModelAndView mv=new ModelAndView("index");
mv.addObject("empList", list);
return mv;
} 。。。
}

3.在/gatling/src/main/resources/templates/下书写页面index.html,内容如下:

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table border="1px">
<caption>All employees</caption>
<thead>
<tr><th>id</th><th>name</th><th>salary</th></tr>
</thead>
<tbody>
<tr th:each="item:${empList}">
<td th:text="${item.id}">id</td>
<td th:text="${item.name}">name</td>
<td th:text="${item.salary}">salary</td>
</tr>
</tbody>
</table>
</body>
</html>

4.在浏览器中输入:http://localhost:8080/listemps,就会看到以下页面:

--2020-04-29--

把Employees显示在页面上的更多相关文章

  1. 【WPF学习笔记】之如何把数据库里的值读取出来然后显示在页面上:动画系列之(六)(评论处有学习资料及源码)

    (应博友们的需要,在文章评论处有源码链接地址,以及WPF学习资料.工具等,希望对大家有所帮助) ...... 承接系列五 上一节讲了,已经把数据保存到数据库并且删除数据,本讲是把已经存在的数据从数据库 ...

  2. echarts如何显示在页面上

    echarts如何显示在页面上 1.引入echarts的相关.js文件 <script src="js/echarts.min.js"></script> ...

  3. 数据量大的数据转换成jason并显示在页面上

    代码列子: public ActionResult FindUserByUserId(SysMessageDTO model) { CustomResultMsg customResult = new ...

  4. js获取当前时间显示在页面上

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  5. struts中用kindeditor实现的图片上传并且显示在页面上

    做公司网站的时候由于需要在内容属性中加入图片,所以就有了这个问题,本来一开始找几篇文章看都是讲修改kindeditor/jsp/file_manager_json.jsp和upload_json.js ...

  6. WordPress 之 在注册界面 实现 注册后密码直接显示在页面上

    前言:WordPress 功能无疑强大的,但有些功能实现上还是有少许不尽人意,比如在 网站上有新用户注册后,必须下发到用户填写的邮件才能接收到新密码,而密码又是系统自动生成的,如果因为某些原因用户接收 ...

  7. vue 上传文件 并以表格形式显示在页面上

    先上代码 <label for="file" class="btn">多文件上传</label> <input type=&quo ...

  8. 微信小程序云开发-云存储-上传单张照片到云存储并显示到页面上

    一.wxml文件 页面上写上传图片的按钮,按钮绑定chooseImg. <button bindtap="chooseImg" type="primary" ...

  9. HTML标签显示在页面上

    用 <xmp></xmp> 标签包起来,里面的所有文字会原样显示出来 <xmp><P>1</P><div>2</div&g ...

随机推荐

  1. SpringCloud系列之API网关(Gateway)服务Zuul

    1.什么是API网关 API网关是所有请求的入口,承载了所有的流量,API Gateway是一个门户一样,也可以说是进入系统的唯一节点.这跟面向对象设计模式中的Facet模式很像.API Gatewa ...

  2. C#设计模式之2-抽象工厂模式

    抽象工厂模式(Abstract Factory Pattern) 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/391 ...

  3. C#LeetCode刷题之#409-最长回文串(Longest Palindrome)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3788 访问. 给定一个包含大写字母和小写字母的字符串,找到通过这 ...

  4. 可以用命令行控制eclipse断点增加删除、远程调试创建与启动的插件

    java # 创建断点(支持条件断点) curl -X PUT -H "Content-Type:application/json" --data '{"language ...

  5. Python 使用BrowserMob Proxy + selenium 获取Ajax加密数据

    BrowserMob Proxy,简称 BMP,它是一个 HTTP 代理服务,我们可以利用它截获 HTTP 请求和响应内容. 第一步:先安装 BrowserMob Proxy 的包. pip inst ...

  6. Ubuntu LNMP环境的搭建

    一.安装nginx Step1:安装: sudo apt-get install nginx Step2:查看ngnix 运行状态 : service nginx status 查看80端口是否开启: ...

  7. Java中实现十进制数转换为二进制的三种方法

    第一种:除基倒取余法 这是最符合我们平时的数学逻辑思维的,即输入一个十进制数n,每次用n除以2,把余数记下来,再用商去除以2...依次循环,直到商为0结束,把余数倒着依次排列,就构成了转换后的二进制数 ...

  8. SpringBoot--- Shiro(拦截,认证)、Thymeleaf(模板引擎)

    SpringBoot--- Shiro(拦截,认证).Thymeleaf(模板引擎) 环境 IDEA :2020.1 SpringBoot: 2.3.3 Java : 8 版本依赖: ​ shiro- ...

  9. On the Convergence of FedAvg on Non-IID Data

    郑重声明:原文参见标题,如有侵权,请联系作者,将会撤销发布! arXiv:1907.02189v2 [stat.ML] 8 Oct 2019 Abstract 联邦学习使得大量的边缘计算设备在不共享数 ...

  10. Hive SQL 优化面试题整理

    Hive优化目标 在有限的资源下,执行效率更高 常见问题: 数据倾斜 map数设置 reduce数设置 其他 Hive执行 HQL --> Job --> Map/Reduce 执行计划 ...