在使用阿里的`JSONArray.toJSONString(resultMap)` 卡住不动的问题

在使用阿里的JSONArray.toJSONString(resultMap) 卡住不动的问题

问题:

​ 卡住不动。

解决:

​ 待解决。。。

<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>1.2.61</version>
    </dependency>
//万能的MAP:结果集
Map<String,String> resultMap = new HashMap<>();

if(o != null){
    if(oldpassword == null){
        resultMap.put("result","error");
    }else if(((User)o).getUserPassword().equals(oldpassword)){
        resultMap.put("result","true");
    }else {
        resultMap.put("result","false");
    }
}else{
    resultMap.put("result","sessionerror");
}

/*
	resultMap = {result=false}
	Json格式:{key:value}
 * */

resp.setContentType("application/json");
PrintWriter writer = resp.getWriter();

//使用ali的这个会卡在这,不知道为啥
writer.write(JSONArray.toJSONString(resultMap));
writer.flush();
writer.close();
posted @ 2022-06-21 23:36  z-laoyao  阅读(110)  评论(0编辑  收藏  举报