source is null for getProperty(null, "xxx")
来源:互联网 发布:重装mac磁盘工具 编辑:程序博客网 时间:2024/05/18 23:14
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'itemCustom.title'. Cause: org.apache.ibatis.ognl.OgnlException: source is null for getProperty(null, "title")
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
at com.sun.proxy.$Proxy24.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy31.findItemList(Unknown Source)
at com.taotao.service.impl.ItemServiceImpl.findItemsList(ItemServiceImpl.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
at com.sun.proxy.$Proxy24.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:119)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
at com.sun.proxy.$Proxy31.findItemList(Unknown Source)
at com.taotao.service.impl.ItemServiceImpl.findItemsList(ItemServiceImpl.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
部分异常,显示为source is null for getProperty(null, "title"),其实就是itemCustom对象为空,一个空指针异常,所以获取不到title属性,之前的mapper.xml代码为
<select id="findItemList" parameterType="com.taotao.wto.ItemCustomVo"resultType="com.taotao.wto.ItemCustom"></select>
<!--为sql加上验证,另外使用动态sql: --><sql id="query_items_where"><!-- 使用动态sql,即要通过if判断,判断的是查询条件 --><if test="itemCustom!=null"><if test="itemCustom.title!=null and itemCustom.title!='' ">tb_item.title LIKE '%${itemCustom.title}%'</if></if></sql><select id="findItemList" parameterType="com.taotao.wto.ItemCustomVo"resultType="com.taotao.wto.ItemCustom"></select>SELECT tb_item.* FROM tb_item <where><include refid="query_items_where"></include></where></select>
阅读全文