将list转为json字符串
生活随笔
收集整理的這篇文章主要介紹了
将list转为json字符串
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
//確保JSP和servlet的編碼方式一致
resp.setContentType("text/html;charset=GBK");
List<String> jymdList = new ArrayList<String>();
PrintWriter out = null;try {//從數(shù)據(jù)庫中取得ListjymdList = efileViewUiService.getLymd();//簡單粗暴,對于Map這句也適用String json = JSON.toJSONString(jymdList);//取得流向JSP傳遞數(shù)據(jù) PrintWriter out = resp.getWriter();out.print(json);} catch (BaseException e) {e.printStackTrace();} finally{out.close(); }復制代碼
?
轉(zhuǎn)載于:https://www.cnblogs.com/panxuejun/p/6148592.html
總結(jié)
以上是生活随笔為你收集整理的将list转为json字符串的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TP框架中的A方法和R方法
- 下一篇: 用鼠标旋转图像