当我尝试迭代BeanMap中的入口集时,我得到了一个
"java.lang.IllegalAccessException: Class org.apache.commons.beanutils.BeanMap can not access a member of class com.hello.Employee with modifiers "public"
at org.apache.commons.beanutils.BeanMap.get(BeanMap.java:391)
at org.apache.commons.beanutils.BeanMap$12.next(BeanMap.java:566)
at org.apache.commons.collections.iterators.UnmodifiableIterator.next(UnmodifiableIterator.java:72)
at org.codehaus.jackson.map.ser.std.MapSerializer.serializeFields(MapSerializer.java:232)
at org.codehaus.jackson.map.ser.std.MapSerializer.serialize(MapSerializer.java:186)
at org.codehaus.jackson.map.ser.std.MapSerializer.serialize(MapSerializer.java:23)
at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:610)
at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
at org.codehaus.jackson.map.ObjectWriter._configAndWriteValue(ObjectWriter.java:456)
at org.codehaus.jackson.map.ObjectWriter.writeValueAsString(ObjectWriter.java:393)
知道可能导致什么原因吗?
答案 0 :(得分:0)
在“com.hello.Employee”类中添加一个公共修饰符解决了这个问题。