list集合转换成json类型
2024-08-22 23:44:19
public String gettext(HttpServletRequest request,HttpServletResponse response){
List<xuanhuan_> xuanhuan = service.getxuanhuan();
JSONArray json = JSONArray.fromObject(xuanhuan);
System.out.println(json);//在这里可以看到,json类型可以直接打印出来
return "/index";
}
打印结果:
[{"content":"","id":0,"name":"《测试》1","shijian":null},{"content":"","id":0,"name":"《测试》2","shijian":null},{"content":"","id":0,"name":"《测试》3","shijian":null},{"content":"","id":0,"name":"《测试》4","shijian":null},{"content":"","id":0,"name":"《测试》5","shijian":null},null,null,null]
下载是maven引入json的包:
<!-- json的包,不是项目自带的 --> <dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
最新文章
- CPU acceleration status: HAXM is not installed on this machine解决方法
- Python之路----------time模块
- android ImageView组件属性
- TYVJ 1074 武士风度的牛
- 线程变量(ThreadLocal)的使用和测试
- DWZ的选择带回功能无法带回第一个value中的值
- dump java
- mobilize扁平化的fullPage.js类工具使用心得
- 初识Selenium(三)
- Chapter 3. Video Coding Concepts
- web前端vertical-align的作用及对象详解
- SPATRA的使用
- Spring学习笔记5——注解方式AOP
- 如何运行一个Vue项目
- mysql两条sql合并查询总数
- Codeforces Round #426 (Div. 2) A,B,C
- <;------------------字节流--------------------->;
- Go 协程编程感悟
- Codeforces Round #427 (Div. 2) D dp
- python下使用tesserocr遇到的一些坑