情况是这样的:
1、我的系统架构是前端c/s,后端用的b/s响应,接口是httpclient,采用http协议交互
2、我在后端查询得到数据,比如一个账号列表,我是以分页形式查询得到,并json返回
Page<Record> pageData = service.query(account, pageNumber, pageSize);
String jsonData = JFinalJson.getJson().toJson(pageData);
renderJson(jsonData);
3、前端,该怎么获取到和后端一样的分页形式呢?pageData<Record>
我用下面形式:
Page<Record> pageData = (Page<Record>)(JSON.parseObject(EntityUtils.toString(responseEntity), Page.class));
调试发现,分页数据是正确的,但以pageData.getList().get(i)获取record,就打印异常
也就是说,传送是正确的,转换也是正确的,但获取pageData.getList().get(i),就 异常
java.lang.ClassCastException: com.alibaba.fastjson.JSONObject cannot be cast to com.jfinal.plugin.activerecord.Record
前端,我该怎么去做转换呢
项目:JFinal
{
submitter:admin,
roleid:0,
sex:1,
telephone:123456,
ifmarked:1,
remark:null,
password:123,
lasttime:2019-09-23 15:23:48.0,
surname:张三,
id:1,
empcode:z00001,
email:123@qq.com,
username:admin,
onoff:1}
返回前端的信息如下:
{
"email":"123@qq.com",
"empcode":"z00001",
"id":1,
"ifmarked":1,
"lasttime":"2019-09-23 15:23:48",
"onoff":1,
"password":"123",
"roleid":0,
"sex":1,
"submitter":"admin",
"surname":"张三",
"telephone":"123456",
"username":"admin"
}