栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Mybatis中报“There is no getter for property named ‘XXX‘ in class java.lang.String“

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Mybatis中报“There is no getter for property named ‘XXX‘ in class java.lang.String“

XXMapper.xml 如下:

    
    
        select count(URL) TOTALCOUNT FROM TC_LOG 
        
        where RESULT=#{result}
        
    

Dao层 如下:

	public int getLogCount(String result);

在调用的时候:

严重: Servlet.service() for servlet [springMVC] in context with path [/UAP] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘result’ in ‘class java.lang.String’] with root cause
org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘result’ in 'class java.lang.String’

解决:

第一种方法:发现问题出在映射文件里,如果参数使用java.lang.String的时候,需要将result改成_parameter来判断是否为空,否则它回去String这个类型里找result的getter方法,所以无法找到。
修改XXMapper.xml:

第二种方法:将result标记为mybatis可识别的标识,这样也不会去调用String这个类型里找result的getter方法。
修改Dao

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/490507.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号