把Employees显示在页面上
项目代码下载: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显示在页面上的更多相关文章
- 【WPF学习笔记】之如何把数据库里的值读取出来然后显示在页面上:动画系列之(六)(评论处有学习资料及源码)
(应博友们的需要,在文章评论处有源码链接地址,以及WPF学习资料.工具等,希望对大家有所帮助) ...... 承接系列五 上一节讲了,已经把数据保存到数据库并且删除数据,本讲是把已经存在的数据从数据库 ...
- echarts如何显示在页面上
echarts如何显示在页面上 1.引入echarts的相关.js文件 <script src="js/echarts.min.js"></script> ...
- 数据量大的数据转换成jason并显示在页面上
代码列子: public ActionResult FindUserByUserId(SysMessageDTO model) { CustomResultMsg customResult = new ...
- js获取当前时间显示在页面上
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- struts中用kindeditor实现的图片上传并且显示在页面上
做公司网站的时候由于需要在内容属性中加入图片,所以就有了这个问题,本来一开始找几篇文章看都是讲修改kindeditor/jsp/file_manager_json.jsp和upload_json.js ...
- WordPress 之 在注册界面 实现 注册后密码直接显示在页面上
前言:WordPress 功能无疑强大的,但有些功能实现上还是有少许不尽人意,比如在 网站上有新用户注册后,必须下发到用户填写的邮件才能接收到新密码,而密码又是系统自动生成的,如果因为某些原因用户接收 ...
- vue 上传文件 并以表格形式显示在页面上
先上代码 <label for="file" class="btn">多文件上传</label> <input type=&quo ...
- 微信小程序云开发-云存储-上传单张照片到云存储并显示到页面上
一.wxml文件 页面上写上传图片的按钮,按钮绑定chooseImg. <button bindtap="chooseImg" type="primary" ...
- HTML标签显示在页面上
用 <xmp></xmp> 标签包起来,里面的所有文字会原样显示出来 <xmp><P>1</P><div>2</div&g ...
随机推荐
- JS 动画笔记
动画实现原理 核心原理:通过定时器setInterval()不断地移动盒子的位置 缓动动画原理 缓动的核心算法~~~~~~~~~~(目标值-现在的位置)/10 停止的条件是~~ ...
- JVM与Java体系结构
参考笔记:https://blog.csdn.net/weixin_45759791/article/details/107322503 前言 作为Java工程师的你曾被伤害过吗?你是否也遇到过这些问 ...
- maven配置问题
今天配置maven环境,最后总是显示 百度好多方法,都没解决,最后查看了一下maven目录下的mvn.cmd文件发现里面的jdk引用名用的是%JAVA_HOME%..... 看完就发现问题了,自己装了 ...
- 怎么用 Solon 开发基于 undertow jsp tld 的项目?
Solon 开发 jsp 还是简单的,可以有 jetty 启动器 或者 undertow 启动器.此文用 undertow + jsp + tld 这个套路搞一把: 一. 开始Meven配置走起 用s ...
- Linux(Centos 7)下安装Git并配置连接GitHub
1.安装git Centos7 查看git --version 2.配置用户名密码 git config --global user.name "xxx" git config ...
- SpringCloudAlibaba-服务容错Sentinel(入门)
一:高并发带来的问题? 在微服务架构中,我们将业务拆分成一个个的服务,服务与服务之间可以相互调用,但是由于网络原因或者自身的原因,服务并不能保证服务的100%可用,如果单个服务出现问题,调用这个服务就 ...
- 【Linux】linux history命令执行后显示历史命令执行时间
vim ~/.bashrc 或者 ~/.bash_profile 或者 获取root权限修改vim /etc/profile 最后添加 export HISTTIMEFORMAT="%F ...
- 面试中HashMap链表成环的问题你答出了吗
HashMap作为老生常谈的问题,备受面试官的青睐,甚至成为了面试必问的问题.由于大量的针对HashMap的解析横空出世,面试官对HashMap的要求越来越高,就像面试官对JVM掌握要求越来越高一样, ...
- Linux 常用软件清单
Linux 常用软件清单 下面是Linux环境的一些软件(有些只是关键字,直接搜素即可): arch 系列的是 pacman -Ss <关键字> debian 系列的是 apt searc ...
- Ubuntu18.04 解决umount: /mnt: device is busy
通过该命令查看那个进程占用该device fuser -m /mnt 然后 kill -9 PID 最后就可以umount /mnt 了