最近在使用适配器接收参数的时候,发现一个很奇怪的现象: 页面传过来的参数在反序列化的时候 对 具有相同变量名的对象都会尝试转换,导致报了类型转换错误
想知道有没有什么方法解决这一问题
上代码
入口函数的定义为:
.
@At(value = "/?")
@PUT
public void update(@Param("..") UserRegistVo userVo) {
//do other
}
这是页面传来的参数对象
public class UserRegistVo {
private User user;
private String[] roles;
private String userid;
}
这是 user 对象
public class User {
private String name;
private List<UserRole> roles;
}
这是报错信息
org.nutz.castor.FailToCastObjectException: Fail to cast from <java.lang.String> to <com.tzding.tzd.entity.acl.UserRole> for {XXXX}
at org.nutz.castor.Castors.cast(Castors.java:263)
at org.nutz.castor.Castors.castTo(Castors.java:317)
at org.nutz.mapl.impl.convert.ObjConvertImpl.injectCollection(ObjConvertImpl.java:188)
at org.nutz.mapl.impl.convert.ObjConvertImpl.inject(ObjConvertImpl.java:85)
at org.nutz.mapl.impl.convert.ObjConvertImpl.convert(ObjConvertImpl.java:72)
at org.nutz.mapl.Mapl.maplistToObj(Mapl.java:34)
at org.nutz.mapl.impl.convert.ObjConvertImpl.injectObj(ObjConvertImpl.java:248)
at org.nutz.mapl.impl.convert.ObjConvertImpl.inject(ObjConvertImpl.java:91)
at org.nutz.mapl.impl.convert.ObjConvertImpl.convert(ObjConvertImpl.java:72)
at org.nutz.mapl.Mapl.maplistToObj(Mapl.java:34)
at org.nutz.mapl.impl.convert.ObjConvertImpl.injectObj(ObjConvertImpl.java:248)
at org.nutz.mapl.impl.convert.ObjConvertImpl.inject(ObjConvertImpl.java:91)
at org.nutz.mapl.impl.convert.ObjConvertImpl.convert(ObjConvertImpl.java:72)
at org.nutz.mapl.Mapl.maplistToObj(Mapl.java:34)
at org.nutz.mvc.adaptor.injector.JsonInjector.get(JsonInjector.java:34)
反序列化的时候 找到 UserRegistVo 的 roles 了 还会继续试图转化成 User 对象里 roles,我并不想让他转化,有什么办法吗