springmvc responsebody亂碼

很簡單,我的做法是在@RequestMapping中添加produces = "application/json; charset=utf-8"

請看如下代碼:

@RequestMapping(value="selectAll",method=RequestMethod.GET,produces = "application/json; charset=utf-8")
	@ResponseBody
	public String selectAll(){
		
		List<Dwxx> dwxxs = dwxxService.selectAll();
		
		JSONObject jsonObject = new JSONObject();
		
		jsonObject.put("dwxxs", dwxxs);
		jsonObject.put("success", true);
		
		return JSON.toJSONString(jsonObject);
	}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章