我试图将 long 转换为 int,但失败了。如果这很重要,我会在 Google App Engine 的 Servlet 中使用。我已经对post1,post2文档进行了搜索,但我的日志中没有结果。指向这一行:
//fields
private int multiplyer;
private Map<String, Object> mappings;
//the method
Echo.log.info("key: "+WinningSetMappingEnum.multiplyer.toString()
+" value: "
+mappings.get(WinningSetMappingEnum.multiplyer.toString())
+" "
+mappings.get(WinningSetMappingEnum.multiplyer.toString()).getClass().getName()
);//For logging
multiplyer=(Integer)mappings.get(MappingEnum.multiplyer.toString());//PROBLEM
日志:
com.wtsang02.deserlizeMapping: key: multiplyer value: 0 java.lang.Long
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer