使用PrintWriter.write输出Json,在前台怎么编译
1个回答
展开全部
a code?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@RequiresPermissions("expertinfo:expInfo:view")
@RequestMapping(value="init")
public void init(HttpServletRequest request,HttpServletResponse response){
List<ExpInfo> expInfos = expInfoService.getRandom(request.getParameter("all")==null?"":request.getParameter("all"));
/* 设置格式为text/json */
response.setContentType("text/json");
/* 设置字符集为'UTF-8' */
response.setCharacterEncoding("UTF-8");
try {
PrintWriter write = response.getWriter();
write.write(getJson(expInfos, 10));
write.flush();
write.close();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@RequiresPermissions("expertinfo:expInfo:view")
@RequestMapping(value="init")
public void init(HttpServletRequest request,HttpServletResponse response){
List<ExpInfo> expInfos = expInfoService.getRandom(request.getParameter("all")==null?"":request.getParameter("all"));
/* 设置格式为text/json */
response.setContentType("text/json");
/* 设置字符集为'UTF-8' */
response.setCharacterEncoding("UTF-8");
try {
PrintWriter write = response.getWriter();
write.write(getJson(expInfos, 10));
write.flush();
write.close();
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询