最近感覺好累,不過總算把配置權限搞定了,期間出了好多各種各樣的問題,特別是配置文件上,很容易就出問題了。
1.可以直接訪問項目的一個方法,然後用PrintWriter 的方式顯示:
// IO流輸出JSON
public static void toOutputJSON(HttpServletResponse response,String json) {
PrintWriter out = null;
try {
out = response.getWriter();
logger.info("json :" + json);
} catch (IOException e) {
logger.error("JSON輸出異常", e);
} finally {
out.write(json);
out.flush();
out.close();
}
}
json是你要返回的數據,JSON.toJsonString(待轉換的數據,object)轉成String
調用:finally {
toOutputJSON(response, json);
}
2.Maven的一些操作
加油!