MyBatis 参数类型为String

mybatis mapper.xml sql 

当parameterType为String时

任何参数都必须为_parameter

正确写法:

[html] view plain copy
  1. xml version="1.0" encoding="UTF-8" ?>  
  2. >  
  3. <mapper namespace="com.stu.mapper.UserMapper">  
  4.   
  5.     <select id="logconfirm" parameterType="String" resultType="String">  
  6.         select password from user where username=#{_parameter}  
  7.     select>  
  8.   
  9. mapper>  

之前写的是

然后提示错误There is no getter of  'username' in java.lang.string

[html] view plain copy
  1. xml version="1.0" encoding="UTF-8" ?>  
  2. >  
  3. <mapper namespace="com.stu.mapper.UserMapper">  
  4.   
  5.     <select id="logconfirm" parameterType="String" resultType="String">  
  6.         select password from user where username=#{username}  
  7.     select>  
  8.   
  9. mapper> 

你可能感兴趣的:(MyBatis)