Parameter 'email' not found. Available parameters are [0, 1, param1, param2]解决方案

转自:https://blog.csdn.net/wdehxiang/article/details/77619569

原因:

传入多个值时,mybatis会自动将这些值转成类似map形式的值,以0,1,2…的序列为keyName。 
这里我们需要先简单了解一下mybatis的传值机制。Mybatis现在可以使用的parameterType有基本类型和Java负责类型

基本数据类型:包含int,String,Date等。基本数据类型作为传参,只能传入一个。通过#{参数名}获取。 
复杂数据类型:包含Java实体类、Map。通过#{属性名}或#{map的keyName}获取。

解决方案:

方案一、在Dao层mapper接口的方法中,为每个参数添加@Param注解

1 public User login(@Param(value="email") String email, @Param(value="password") String password);
1 <select id="login" resultType="User"  parameterType="String">
2       select * from user where email=#{email} and password=#{password}
3 </select>

方案二:将多个值存入Map中

1 public User login(HashMap<String,String) map);
1 <select id="login" resultType="User"  parameterType="Map">
2       select * from user where email=#{email} and password=#{password}
3 </select>

方案三:以传递参数的顺序通过#{0},#{1}获取

1 public User login(String email, String password);
1 <select id="login" resultType="User"  parameterType="String">
2          select * from user where email=#{0} and password=#{1}
3 </select>

Parameter 'email' not found. Available parameters are [0, 1, param1, param2]解决方案

原文地址:https://www.cnblogs.com/java-dyb/p/10894839.html

时间: 2024-10-07 23:26:13

Parameter 'email' not found. Available parameters are [0, 1, param1, param2]解决方案的相关文章

解决Parameter &#39;offset&#39; not found. Available parameters are [0, 1, param1, param2]的方法

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'offset' not found. Available parameters are [0, 1, param1, param2] at org.mybatis.spring.MyBatisExceptionTranslator.translateExcepti

Parameter &#39;name&#39; not found. Available parameters are [arg1, arg0, param1, param2]

解决方法: <select id="selectIf" resultType="student"> SELECT id,name,age,score FROM t_student WHERE 1=1 <if test="arg0 != null and arg0 !=''"> AND name LIKE '%' #{arg0} '%' </if> <if test="arg1>=0&quo

org.apache.ibatis.binding.BindingException: Parameter &#39;xxx&#39; not found. Available parameters are [arg1, arg0, param1, param2]

这个异常说明参数没有加上@Param注解,加上这个注解就行了. org.apache.ibatis.binding.BindingException: Parameter 'xxx' not found. Available parameters are [arg1, arg0, param1, param2] 原文地址:https://www.cnblogs.com/FengZeng666/p/12012727.html

java 传入多个参数时报&quot;Parameter &#39;XXX&#39; not found. Available parameters are [arg1, arg0, param1,...&quot; 解决方案

@Select("SELECT id FROM ae_post ORDER BY id DESC LIMIT #{page},#{size}") List<Post> getAllForPage(@Param("page") int page, @Param("size")int size); dao层写入,解决方法如上 注:多参数需要添加 @Param("参数名") int 参数名 java 传入多个参数时报&q

org.apache.ibatis.binding.BindingException: Parameter &#39;start&#39; not found. Available parameters are [1, 0, param1, param2]

DEBUG 2018-05-30 08:43:26,091 org.springframework.jdbc.datasource.DataSourceTransactionManager: Rolling back JDBC transaction on Connection [[email protected]]DEBUG 2018-05-30 08:43:26,091 org.mybatis.spring.SqlSessionUtils$SqlSessionSynchronization:

初学Java9:学习Mybatis时报错:Parameter &#39;name&#39; not found. Available parameters are [1, 0, param1, param2]

报错-->Parameter 'name' not found. Available parameters are [1, 0, param1, param2] 百度找到这篇文章完成修改 http://blog.csdn.net/w86440044/article/details/29363067 我之前写的操作类是和博主一样,是这样的: 1 // 登录·查询 2 @Select("select * from t_users where uname=#{name} and pswd=#{p

Mybatis错误:Parameter &#39;XXX&#39; not found. Available parameters are [1, 0, param1, param2]

Mybatis错误:Parameter 'XXX' not found. Available parameters are [1, 0, param1, param2] 原因:传递的参数超过一个 记 解决办法: (1)直接把值改成数字 <select id="LoginUser" parameterType="String" resultMap="userMap"> SELECT * FROM user where emplnumb

mybatis:Parameter &#39;list&#39; not found. Available parameters are [templateId, param1, param2, valueList]

我的EsdTemplateSealMapper.java里面定义的接口是这样的 public List<EsdTemplateSeal> getFilteOutSeal(@Param("filterList")List<String> list,@Param("templateId")String templateId); 然后我的EsdTemplateSealMapper.xml里面的sql是这样的: <select id="

【Mybatis异常】 org.apache.ibatis.binding.BindingException: Parameter &#39;storeId&#39; not found. Available parameters are [form, param1]

一.异常信息 2019-05-31 16:06:25.272 [http-nio-10650-exec-3] WARN o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver.logException(AbstractHandlerExceptionResolver.java:192) - Resolved exception caused by Handler execution: org.mybatis.spring.MyBatisSystemExce