package com.example.demo0508.controller;
import com.example.demo0508.entity.TMsg;
import com.example.demo0508.service.TMsgService;
import com.google.gson.Gson;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/msg")
public class TMsgController {
private final TMsgService tMsgService;
public TMsgController(TMsgService tMsgService) {
this.tMsgService = tMsgService;
}
@GetMapping("/getJson") // 通过Message获取id
public String getJson(@Param("id") Integer id){
TMsg tMsg = tMsgService.findById(id);
Gson gson = new Gson();
return gson.toJson(tMsg);
}
@GetMapping("/getAllJson") // 通过Message获取id
public String getAllJson(){
List<TMsg> list = tMsgService.findTMsgAll();
Gson gson = new Gson();
return gson.toJson(list);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
大家可以在B站一步一步跟着视频敲。我只写了后端,只可以调用API,没有写前端的东西,不过问题不大,这个和视频里的代码一样样的,就是我看着敲的,如果你想的话,自己继续跟着视频敲完就行。 后端 SpringBoot + MyBatis , 前端 Ajax + jQuery + CSS + HTML,详细讲解了后端接口数据设计和使用,前端数据请求和响应填充界面的过程,数据库采用 MySQL8.0.24,1小时搞懂前后端开发的关键技术和开发架构。 视频链接: 【Springboot整合MyBatis通过ajax查询MySQL数据库数据】 https://www.bilibili.com/video/BV1Nb4y1f76T/?share_source=copy_web&vd_source=33606ec04709ac5145579443fb0af1b2
资源推荐
资源详情
资源评论
收起资源包目录
demo0508.zip (24个子文件)
demo0508
HELP.md 1KB
mvnw.cmd 7KB
pom.xml 2KB
src
test
java
com
example
demo0508
Demo0508ApplicationTests.java 223B
main
resources
mapper
TMsgMapper.xml 647B
templates
static
application.yml 327B
java
com
example
demo0508
mapper
TMsgMapper.java 413B
Demo0508Application.java 329B
controller
TMsgController.java 1KB
service
TMsgService.java 292B
impl
TMsgServiceImpl.java 778B
entity
TMsg.java 202B
.mvn
wrapper
maven-wrapper.properties 1019B
maven-wrapper.jar 59KB
.idea
jarRepositories.xml 864B
dataSources
dataSources.local.xml 641B
workspace.xml 5KB
misc.xml 539B
dataSources.xml 541B
compiler.xml 935B
.gitignore 190B
encodings.xml 191B
mvnw 10KB
.gitignore 395B
共 24 条
- 1
资源评论
为了孩子他娘而奋斗
- 粉丝: 70
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功