`
samwalt
  • 浏览: 287260 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

org.apache.ibatis.reflection.ReflectionException: There is no getter for propert

    博客分类:
  • java
 
阅读更多
在使用mybatis的模糊查询的时候,需要从jsp传入到controller中一个keyword【String】,在mapper.xml中我是这样写的

    <select id="fuzzyFind" resultMap="articleResultMap" parameterType="string">  
        <![CDATA[ 
            SELECT * FROM articles WHERE 1=1 
        ]]>  
        <if test="keyword != null">  
            <![CDATA[ AND article_title LIKE CONCAT('%','${keyword}','%') ]]>  
        </if>  
    </select>  


然后用junit测试的时候,后台报了org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'keyword' in 'class java.lang.String'这样的一个错误,说keyword这个属性没有getter方法,然而我这个keyword不是javabean,没有必要为其设置getter方法,那怎么办呢?我在网上看到了这样的几种解决方法:

1. 将string类型换成map类型的,然后将该keyword 放入该map中,不会报错

2. 在接口中使用@Param(value="xxx") String xxx, 例如:public List<ArticleEntity> fuzzyFind(@Param(value = "keyword") String keyword);  也可以解决问题, 但是我这样写还是出现了同样的错误

3. 在配置文件中直接将keyword换成_parameter,问题解决。
    <select id="fuzzyFind" resultMap="articleResultMap" parameterType="string">  
        <![CDATA[ 
            SELECT * FROM articles WHERE 1=1 
        ]]>  
        <if test="_parameter != null">  
            <![CDATA[ AND article_title LIKE CONCAT('%','${_parameter}','%') ]]>  
        </if>  
    </select>  
分享到:
评论

相关推荐

    ibatis-core-3.0.jar org.apache.ibatis.annotations.Param

    `org.apache.ibatis.annotations.Param`是MyBatis中的一个重要注解,用于处理方法参数映射。 `@Param`注解主要用于SQL查询中的动态参数绑定,尤其是在动态SQL语句中。在MyBatis的映射文件或者Mapper接口中,当我们...

    mybatis源码中文注释.zip

    org.apache.ibatis.logging org.apache.ibatis.logging.commons org.apache.ibatis.logging.jdbc org.apache.ibatis.logging.jdk14 org.apache.ibatis.logging.log4j org.apache.ibatis.logging.log4j2 org.apache....

    ibatis-2.3.4.726.jar,ibatis-2.3.0.677.jar,ibatis-2.3.3.720.jar下载

    iBATIS,全称为“Infrastructure for Binding Applications To SQL Maps”,是一个优秀的开源持久层框架,它允许Java开发者将SQL语句与Java代码分离,提供了一种简单但强大的在Java应用中映射SQL和结果集的方式。...

    前端-后端java的Util类的工具类

    │ │ │ frame-sourcefiles-org.apache.ibatis.reflection.property.html │ │ │ frame-sourcefiles-org.apache.ibatis.reflection.wrapper.html │ │ │ frame-sourcefiles-org.apache.ibatis.scripting....

    learn-mybatis-plus:学习mybatis-plus配置,解决save时乱码,解决mybatis映射时日期格式问题。为什么不用mybatis-plus-boot-starter?配置多数据源时,要让spring-boot不自动注入data-source和sqlSessionFactory。

    常问问题1,出现了如下BUG org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'statement' in 'class ...

    iBatis框架搭建用到的所有jar包

    纵观目前主流的 ORM(对象关系映射),无论 Hibernate还是Apache OJB,都对数据库结构提供了较为完整的封装,提供了从POJO到数据库表的全套映射机制。程序员往往只需定义好了POJO 到数据库表的映射关系,即可通过 ...

    IBATISJDBC包

    1. **IBATIS核心库**: 包含了ibatis-2.x.jar,这是IBATIS框架的主要实现,提供了SQL映射文件解析、事务管理、结果集处理等功能。 2. **JDBC驱动**: 根据实际使用的数据库类型,如MySQL、Oracle、SQL Server等,需要...

    IBatisNet.Common.1.6.2、IBatis.DataAccess.1.9.2、IBatis.DataMapper.1.6.2

    标题和描述中提到的"IBatisNet.Common.1.6.2、IBatis.DataAccess.1.9.2、IBatis.DataMapper.1.6.2"是针对一个名为IBatisNet的框架的不同组件的版本号。IBatisNet是一个在.NET平台上实现的开源持久层框架,它源于Java...

    mybaits refid patch

    Caused By: org.apache.ibatis.builder.BuilderException: Could not find SQL statement to include with refid 'SAD02.SAD02_COL' at org.apache.ibatis.builder.xml.XMLStatementBuilder$IncludeNodeHandler....

    spring lib j2ee

    log4j.addivity.org.apache=true log4j.logger.com.ibatis = ERROR log4j.logger.com.ibatis.common.jdbc.SimpleDataSource = ERROR #log4j.logger.com.ibatis.common.jdbc.ScriptRunner = ERROR #log4j....

    ibatis最新包下载

    要大于20个字符要大于20个字符要大于20个字符要大于20个字符要大于20个字符要大于20个字符要大于20个字符要大于20个字符要大于20个字符

    Spring高版本对ibatis的支持

    &lt;bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"&gt; &lt;value&gt;classpath:SqlMapConfig.xml &lt;bean id="dao" class="org.springframework.orm.ibatis....

    解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found

    出现以上的情况主要的原因是因为在主配置文件标签没正确的指向映射接口的配置文件。 解决方案:1.检查的name是否正确,如我的name属性填的就是com.it.dao 2、检查的class属性或resource属性,我resource这里写的是...

    spring-framework-3.0.5.RELEASE-dependencies-5

    org.apache.ibatis org.apache.juli 4号包: org.apache.tiles org.apache.velocity org.apache.xerces org.apache.xml org.apache.xmlbeans org.apache.xmlcommons org.apache.derby org.apache.poi org.apache....

    spring-framework-3.0.5.RELEASE-dependencies-1

    org.apache.ibatis org.apache.juli 4号包: org.apache.tiles org.apache.velocity org.apache.xerces org.apache.xml org.apache.xmlbeans org.apache.xmlcommons org.apache.derby org.apache.poi org.apache....

    spring-framework-3.0.5.RELEASE-dependencies-6

    org.apache.ibatis org.apache.juli 4号包: org.apache.tiles org.apache.velocity org.apache.xerces org.apache.xml org.apache.xmlbeans org.apache.xmlcommons org.apache.derby org.apache.poi org.apache....

    spring-framework-3.0.5.RELEASE-dependencies-3

    org.apache.ibatis org.apache.juli 4号包: org.apache.tiles org.apache.velocity org.apache.xerces org.apache.xml org.apache.xmlbeans org.apache.xmlcommons org.apache.derby org.apache.poi org.apache....

    spring-framework-3.0.5.RELEASE-dependencies-2

    org.apache.ibatis org.apache.juli 4号包: org.apache.tiles org.apache.velocity org.apache.xerces org.apache.xml org.apache.xmlbeans org.apache.xmlcommons org.apache.derby org.apache.poi org.apache....

Global site tag (gtag.js) - Google Analytics