当前位置:网站首页>Json.tojsonstring cannot pass Boolean
Json.tojsonstring cannot pass Boolean
2022-07-25 04:49:00 【Shuaida's structural road】
JSON.toJSONString Can't pass boolean
In the use of JSON.toJSONString turn json Format time , The back end is springboot, The front is vue, Each return User Objects are always one field short state
User Entity class :
public class User {
private int id;
private String username;
private String password;
private String email;
private String role;
private Boolean state;
Interface :
@RequestMapping("/alluser")
@ResponseBody
public String getUserList(QueryInfo queryInfo) {
int numbers = userDao.getUserCount("%" + queryInfo.getQuery() + "%");
int pageStart = (queryInfo.getPageNum() - 1) * queryInfo.getPageSize();
List<User> users = userDao.getAllUser("%" + queryInfo.getQuery() + "%",pageStart,queryInfo.getPageSize());
HashMap<String, Object> res = new HashMap<>();
res.put("numbers",numbers);
res.put("data",users);
String s = JSON.toJSONString(res);
return s;
}
At first, it was written above , Find out state The field cannot be transferred to the front end , I found a lot of ways on the Internet , Finally, it still couldn't be solved , I heard later that springboot Send data to vue There is no need to turn json, Direct return can also receive , It's changed to the following
@RequestMapping("/alluser")
@ResponseBody
public Map getUserList(QueryInfo queryInfo) {
int numbers = userDao.getUserCount("%" + queryInfo.getQuery() + "%");
int pageStart = (queryInfo.getPageNum() - 1) * queryInfo.getPageSize();
List<User> users = userDao.getAllUser("%" + queryInfo.getQuery() + "%",pageStart,queryInfo.getPageSize());
HashMap<String, Object> res = new HashMap<>();
res.put("numbers",numbers);
res.put("data",users);
return res;
}
Go straight back to Map, All fields can be received at the front end
front end :
data() {
return {
queryInfo: {
query: "",
pageNum: 1,
pageSize: 10,
},
userList: [],
total: null,
},
methods: {
async getUserList() {
const {
data:res} = await this.$http.get("/alluser",{
params: this.queryInfo});
this.userList = res.data;
this.total = res.numbers
}
}
Cannot be state Fields are passed back , The specific reason has not been found , Whether it's change get、set, still JSON.toJSONString When adding those parameters , Doesn't work ~
边栏推荐
- Metinfo function public function getcity() error: XXX function no permission load!!!
- I didn't expect Mysql to ask these questions
- Introduction to FileStream class of C #
- Pychart configuration pyqt5
- [wechat applet] label (86/100)
- The United States has launched 337 investigations on a number of Chinese companies: Bubugao is full of lying guns!
- MySQL -- index and transaction isolation level
- If the development of the metauniverse still follows the development logic of the Internet, and its end point also follows
- [golang from introduction to practice] stone scissors paper game
- Chart is code: build a new generation of graphics library in a coded way -- feekin
猜你喜欢
![[ CTF 学习 ] CTF 中的隐写集合 —— 图片隐写术](/img/32/2da78bd5866cfab9ee64dfcb1c1204.png)
[ CTF 学习 ] CTF 中的隐写集合 —— 图片隐写术

Introduction to CpG control network

Salt and ice particles cannot be distinguished

推荐系统-协同过滤在Spark中的实现

After watching the latest interview with big manufacturers, these six JVM interview questions were asked

Database design process

Burpsuite爆破之token值替换

It we media shows off its wealth in a high profile, and is targeted by hacker organizations. It is bound to be imprisoned

Dark king | analysis of zego low illumination image enhancement technology

【微信小程序】拍卖商品详情页设计与交互实现(包含倒计时、实时更新出价)
随机推荐
What is behind the development of science and technology now is the advent of the era of the meta universe
1. If function of Excel
OA and fansoft Bi cross system users, departments and posts synchronous summary
一般在进行数仓迁移过程中,是如何进行数据测试的?
推荐系统-协同过滤在Spark中的实现
Interview required: how to design the seckill system?
MongoDB的安全认证详解
PyG搭建GCN实现链接预测
After watching the latest interview with big manufacturers, these six JVM interview questions were asked
Dark king | analysis of zego low illumination image enhancement technology
如何取得数据库创建时间?
HTC new VR all-in-one machine vive focus plus release: price 5699 yuan!
Gbase 8A about no suitable driver
LVGL 8.2 Span
[golang from introduction to practice] stone scissors paper game
很多时候都是概率
How to merge cells in a table by markdown
Grafana visual configuration diagram histogram
市场是对的
In the Internet of things market, Bosch sensor has launched a number of new solutions