Resource不能直接返回吗?
老师,Resource不能直接返回吗,为什么需要new一个新的对象,copy一份
老师,Resource不能直接返回吗,为什么需要new一个新的对象,copy一份
2018-03-22
老师,我直接返回Resource报错了,为什么
@RequestMapping("/getResource")
public JsonUtil getResource() {
Resource bean=new Resource();
//BeanUtils.copyProperties(resource, bean);
//System.out.println(resource);
//System.out.println(bean);
return JsonUtil.ok(resource);
}
2018-04-12 13:01:56.862 WARN 10980 --- [nio-8090-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.imooc.util.JsonUtil["date"]->com.imooc.model.Resource$$EnhancerBySpringCGLIB$$21953e4a["$$beanFactory"]->org.springframework.beans.factory.support.DefaultListableBeanFactory["beanExpressionResolver"])
2018-04-12 13:01:56.862 WARN 10980 --- [nio-8090-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.imooc.util.JsonUtil["date"]->com.imooc.model.Resource$$EnhancerBySpringCGLIB$$21953e4a["$$beanFactory"]->org.springframework.beans.factory.support.DefaultListableBeanFactory["beanExpressionResolver"])
举报