NutzCN Logo
问答 RESTFUL返回JSON为什么会在JSON值后面带个null
发布于 3123天前 作者 qq_6b8e56db 2447 次浏览 复制 上一个帖子 下一个帖子
标签:
{"addTime":"2016-06-04 10:56:55","addUnitId":"9bc2dc100fb4487a8828791dedb5fb05","addUser":2,"areaFatherId":0,"areaId":"294","areaName":"中东5","areaRemark":"","currentUnit":"9bc2dc100fb4487a8828791dedb5fb05","currentUserId":2,"editTime":"2016-06-04 10:56:55","editUser":2,"id":236,"isDelete":1,"time":"2016-06-04 11:06:43"}null
3 回复

贴入口方法

@wendal

	/**
	 * 
	 * @description 根据主键查询Bean
	 * 
	 */
	@At("/getBean/?")
	@Ok("json")
	@POST
	public void getBean(@Param("id") Long id) {
		String resjson =  JSON.toJSONString(areaInfoModelService.getById(id));
		try {
			res.getWriter().write(resjson);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

就不应该自行转json

改成这样

	@At("/getBean/?")
	@Ok("json")
	@POST
	public Object getBean(@Param("id") Long id) {
		return areaInfoModelService.getById(id)
	}

添加回复
请先登陆
回到顶部