昨天项目上有个BUG,报了这个错误:
Response content:
{"result":"-1","resultMsg":"java.lang.IllegalArgumentException:
Cannot invoke com.hotent.core.model.BaseModel.setUpdatetime on bean class 'class com.hotent.platform.model.system.Resources'
- argument type mismatch - had objects of type \"java.lang.Long\" but expected signature \"java.util.Date\""}。
调接口的时候传给接口的参数Resources类里Updatetime时间类型date,传递的时候json传的是Long
这样接受参数的时候就报了如上类型不匹配的错误。
解决办法:
params.put("resources", JSON.toJSONString(resources));
改成
params.put("resources", JSON.toJSONStringWithDateFormat(resources,"yyyy-MM-dd"));
接口接收参数的时候做一下处理:
String json = request.getParameter("resources");
JSONObject obj = null;
Resources resources = null;
if(