关于 There is no getter for property named 'id' in 'class java.lang.Integer'

在写SSM框架的时候,请求报出 There is no getter for property named ‘id‘ in ‘class java.lang.Integer‘这个问题

但是实际上实体类中写了相关的方法,最后找到问题出现在Mapper接口中,

 List<User> getAllUser( Integer id);

将代码改为:

List<User> getAllUser(@Param("id") Integer id);

问题解决

方法2

当mapper的方法参数是基础类型且只有一个时,在mapper.xml文件中使用${}取值时,会报There is no getter for property named ‘id‘ in ‘class java.lang.Integer‘异常。

解决方法

1、@Param注解

public AreaDict selectById(@Param("id") Integer id);

select * from area_dict where area_dict_id = ${id}

2、将${}换成#{}取值,#{}能防止sql注入,${}只是简单的字符串替换,#{}先进行预处理

select * from area_dict where area_dict_id = #{id}
3、通过${value}或${_parameter}取值

select * from area_dict where area_dict_id = ${_parameter}

select * from area_dict where area_dict_id = ${value}

关于 There is no getter for property named 'id' in 'class java.lang.Integer'

原文地址:https://www.cnblogs.com/roak/p/12614475.html

时间: 2024-11-02 17:25:00

关于 There is no getter for property named 'id' in 'class java.lang.Integer'的相关文章

MyBatis查询传一个参数时报错:There is no getter for property named &#39;sleevetype&#39; in &#39;class java.lang.Integer

用MyBatis进行查询,传入参数只有一个时(非Map)如int,报错 There is no getter for property named 'sleevetype' in 'class java.lang.Integer 原因在于测试条件写法有误, <if test="sleevetype==0"><!-- 专属 --> exclusive=1 </if> <if test="sleevetype!=0">&l

mybaits错误解决:There is no getter for property named &#39;id&#39; in class &#39;java.lang.String&#39;(转)

在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter来代替参数名. 正确的写法: [html] view plain <span style="font-size:18px;">    <!-- 用于查询运单号是否存在 --> <select id="isCargoBillNoExist" resultType="java.lang.Integer&quo

mybaits错误解决:There is no getter for property named &#39;id&#39; in class &#39;java.lang.String&#39;

在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter 来代替参数名. 正确的写法: [html] view plaincopyprint? <span style="font-size:18px;">    <!-- 用于查询运单号是否存在 --> <select id="isCargoBillNoExist" resultType="java.lang.

org.apache.ibatis.reflection.ReflectionException: There is no getter for property named &#39;fundId&#39; in &#39;class java.lang.Integer&#39;

Struts Problem Report Struts has detected an unhandled exception: Messages: There is no getter for property named 'fundId' in 'class java.lang.Integer' nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for prope

There is no getter for property named &#39;id&#39; in class &#39;java.lang.String&#39;

https://blog.csdn.net/u011897392/article/details/46738747 使用mybatis传入参数,如果在mappin.xml中使用<if>标签判断该参数是否为空,通常会报以上异常,解决方法:?在接口中该方法的参数前加上@Param("参数名")注解,即可? 接口: public interface UserMapper { //根据名称查询用户 List<MAP> queryUserByName(@Param(&qu

错误解决:There is no getter for property named &#39;id&#39; in class &#39;java.lang.String&#39;

使用mybatis传入参数,如果在mappin.xml中使用<if>标签判断该参数是否为空,通常会报以上异常,解决方法:?在接口中该方法的参数前加上@Param("参数名")注解,即可? 错误解决:There is no getter for property named 'id' in class 'java.lang.String' 原文地址:https://www.cnblogs.com/lqh969696/p/11578492.html

关于mybtis 使用过程中发生There is no getter for property named &#39;id&#39; in class &#39;java.lang.String&#39; 错误

今天在修改一个关于mybtis语句时,偶然发现的一个错误  There is no getter for property named 'id' in class 'java.lang.String', 纠结了许久,终于明白了为什么. 原因:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取 string.xxx 值,如果没在在方法中定义,则会抛异常报错.当然也不是所有的版本会有这个问题,我的项目用的版本比较老. 有两种解决方案: 方案一: 将对应的参数用 _parameter

There is no getter for property named &#39;userId&#39; in &#39;class java.lang.String&#39;

[ERROR] 2017-01-18 04:37:06:231 cn.dataenergy.common.CenterHandlerExceptionResolver (CenterHandlerExceptionResolver.java:44) - 统一捕获异常: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Th

org.apache.ibatis.reflection.ReflectionException: There is no getter for property named &#39;parentId&#39; in &#39;class java.lang.String&#39;

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'parentId' in 'class java.lang.String' at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:333) at org.apache.ibatis.reflection.Meta