【发布时间】:2017-06-07 10:54:11
【问题描述】:
我正在尝试调用 json web 服务(在 Liferay 中),特别是上传文件的方法(add-file-entry),在请求的参数中有一个对象 ServiceContext(https://docs.liferay.com/portal/6.2/javadocs/src-html/com/liferay/portal/service/ServiceContext.html#line.69) ,我将此对象参数作为 JSON 字符串发送,并且 json Web 服务必须将 json 字符串反序列化为 ServiceContext 对象。 ServiceContext 有一个属性:
private Map<String, Serializable> _attributes;
当我在这张地图中添加一个条目时:
servicecontext.setAttribute("fileEntryTypeId", 0);
当 GSON 尝试反序列化 servicecontext 对象时:
ServiceContext servicecontext = new Gson().fromJson(ServiceContext, ServiceContext.class);
他抛出异常:无法为接口 java.io.Serializable 调用无参数构造函数。
请帮忙
【问题讨论】:
标签: java json web-services gson liferay