Springboot+Ajax同步实现数据显示
Springboot+Ajax同步实现数据显示
Springboot+Ajax同步实现数据显示
1.步骤一:MySQL数据库中创建表并插入数据
2.步骤二:pojo层代码编写
public class Integral {
//会员账号
private String account;
//用户名
private String userName;
//性别
private String sex;
//会员电话
private String phone;
//邮箱
private String email;
//地址
private String address;
// 加入时间
private Date addressTime;
//账户积分
private int integral;
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public Date getAddressTime() {
return addressTime;
}
public void setAddressTime(Date addressTime) {
this.addressTime = addressTime;
}
public int getIntegral() {
return integral;
}
public void setIntegral(int integral) {
this.integral = integral;
}
3.步骤三:Dao层代码编写
package com.springboot.education.dao;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.springboot.education.pojo.Integral;
@Mapper
public interface IntegralMapper {
//查询所有积分列表
public List findAllIntegral() throws Exception;
4.步骤四:mapper.xml文件编写
/p>
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
select account,userName,sex,phone,email,address,addTime,integral from t_integral
五.步骤五:service层代码编写
package com.springboot.education.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.springboot.education.pojo.Integral;
@Service
public interface IntegralService {
//查询所有积分列表
public List findAllIntegral() throws Exception;
}
六.步骤六:service层实现类代码编写
package com.springboot.education.service.Impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.springboot.education.dao.IntegralMapper;
import com.springboot.education.pojo.Integral;
import com.springboot.education.service.IntegralService;
@Service
public class IntegralServiceImpl implements IntegralService {
@Autowired
private IntegralMapper integralMapper;
@Override
public List findAllIntegral() throws Exception {
// TODO Auto-generated method stub
return integralMapper.findAllIntegral();
}
}
七.Controller层代码编写
package com.springboot.education.controller;
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.bind.annotation.ResponseBody;
import com.springboot.education.pojo.Integral;
import com.springboot.education.service.IntegralService;
/**
* @积分控制类
*
*/
@Controller
@RequestMapping(value="Integral")
public class IntegralController {
@Autowired
private IntegralService integralService;
//查询所有用户积分
@GetMapping("allUser")
@ResponseBody
public List findAllIntegral() throws Exception{
List listIntegral = integralService.findAllIntegral();
for(int i=0;i
System.out.println(listIntegral.get(i).getAccount());
}
return listIntegral;
}
}
}
八.前台Ajax代码编写
/*数据显示*/
$(document).ready(function(){
$.ajax({
type:"get",
url:"http://localhost:8090/Integral/allUser",
async:false,
success:function(data){
for(var i = 0;i
$("#allmember").append(
"
"+"
"+"""+"
"
"+"
"+data[i].account+""+"
"+data[i].userName+""+"
"+data[i].sex+""+"
"+data[i].phone+""+"
"+data[i].email+""+"
"+data[i].address+""+"
"+data[i].addTime+""+"
"+data[i].integral+""+"
\n"+"启用\n"
+"删除\n"
+"
"+"
");}
}
})
})
九.结果
Springboot+Ajax同步实现数据显示相关教程
【Jenkins】一条简单的“java -jar jenkins.war“,轻松实现Jenk
【Jenkins】一条简单的“java -jar jenkins.war“,轻松实现Jenkins部署 文章目录 准备工作 部署 上传文件 启动脚本 启动 修改文件 文件路径 修改内容 重启 准备工作 下载war包: 下载地址 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上
Linux网络通信—Socket(TCP实现)
Linux网络通信—Socket(TCP实现) 一、socket概述 为了简化开发通信程序的工作,由Berkely学校开发了一套网络通信程序的API函数标准。 二、SOCKET分类 流式套接字(SOCK_STREAM) 流式的套接字可以提供可靠的、面向连接的通讯流。它使用了TCP协议。TCP 保证
操作系统:连续内存的分配与回收,C语言实现
操作系统:连续内存的分配与回收,C语言实现 【题目要求】采用连续分配方式之动态分区分配存储管理,使用首次适应算法、循环首次适应算法、最佳适应算法和最坏适应算法4种算法完成设计。 (1)设计一个作业申请队列以及作业完成后的释放顺序,实现主存的分配
Springboot+Mybatis +Mysql 实现登录功能以及遇到的一些问题
Springboot+Mybatis +Mysql 实现登录功能以及遇到的一些问题 本文参考自博客https://blog.csdn.net/baidu_39298625/article/details/98102453 在根据上面博客写功能实现的时候遇到了不少问题,现将遇到的问题描述出来,避免以后再遇到。 1,在没有配置yml文件
操作系统:银行家算法模拟,C语言实现
操作系统:银行家算法模拟,C语言实现 代码如下:(环境VS2019) #includestdio.h#define Pcount 5#define Scount 3//可用资源,最大资源,已分配资源,仍需资源设置为全局变量int Available[Scount];int Max[Pcount][Scount];int Allocation[Pcount][Scount]
利用GreenDao实现本地购物车(一)
利用GreenDao实现本地购物车(一) 最近开发有一个需求就是实现扫一扫,添加商品到购物车,购物车页面添加一个清空按钮,购物车列表页面,可以调整数据,可以增加,减少,与输入数字。 效果大概如图所示: 还有长按删除数据,减少数字到0 时自动删除该项item
编写脚本实现DHCP服务与DHCP中继自动化执行
编写脚本实现DHCP服务与DHCP中继自动化执行 编写脚本实现DHCP服务与DHCP中继自动化执行 本脚本是在liunx搭建DHCP服务器以及DHCP中继服务器实验环境下实现的https://www.cnblogs.com/yuzly/p/10539317.html 源码如下: #!/bin/ bash#该脚本用于自动化配置DHCP
【AQS面试篇】了解ReentrantLock吗?讲讲其底层实现
【AQS面试篇】了解ReentrantLock吗?讲讲其底层实现 AQS知识点 1. ReentrantLock和AQS的关系 AQS原理 2. ReentrantLock锁机制原理 可重入锁 互斥锁 释放锁 3. AQS资源共享方式 4. AQS底层使用了模板方法模式 ReentrantLock为例 CountDownLatch为例 Lock的使用