POST /nutzbook/user/name/ HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{
"id": 1,
"name": "admin",
"password": "",
"salt": "",
"ct": "",
"ut": ""
}
HTTP/1.1 302 Found
Server: Apache-Coyote/1.1
Location: /nutzbook/
Content-Length: 0
Date: Fri, 19 Aug 2016 08:13:34 GMT
代码如下
@At("/name/")
@Ok("json:{locked:'password|salt',ignoreNull:true}") // 忽略password和salt属性,忽略空属性的json输出
@POST
@AdaptBy(type = JsonAdaptor.class)//Json适配器
public String topic( @Param("..") User user) {
System.out.println(user.toString());
NutMap re = new NutMap();
re.put("ok", true);
re.put("data", dao.fetch(User.class, user.getId()));
return Json.toJson(re);
}