$(function(){
var json = {
map : {
1 : 1
}
};
$.ajax({
type : 'POST',
url : "/test",
async : false,// 默认为异步ajax
data : JSON.stringify(json),
dataType : 'JSON',
contentType : 'application/json'
});
});
@At("/test")
@Ok("json")
@AdaptBy(type=JsonAdaptor.class)
public void test(@Param("..")TestModel testModel) {
Map<Integer,Object> map = testModel.getMap();
System.out.println("string类型:" + map.containsKey("1"));
System.out.println("int类型:" + map.containsKey(1));
}
17-10-13 13:11:54.432 DEBUG [http-nio-80-exec-5] Found mapping for [GET] path=/hello : MainMoudle.doHello1(MainMoudle.java:22)
17-10-13 13:11:54.494 DEBUG [http-nio-80-exec-6] Found mapping for [POST] path=/test : MainMoudle.test(MainMoudle.java:29)
string类型:true
int类型:false
import java.util.Map;
public class TestModel {
private Map<Integer,Object> map;
public Map<Integer, Object> getMap() {
return map;
}
public void setMap(Map<Integer, Object> map) {
this.map = map;
}
}