java代码中把参数传递到 mapper.xml 文件

    一个简单参数:
    Dao 接口中方法的参数只有一个简单类型(java 基本类型和 String),占位符**#{**``**任意字符 **``**}**,和方法的参数名无关。
    接口方法:

    1. Student selectById(int id);


    mapper **文件:

    <select id="selectById" resultType="com.bjpowernode.domain.Student">  
          select id,name,email,age from student where id=#{studentId} 
    </select>
    

    #{studentId} , studentId是自定义的变量名称,和方法参数名无关。

    测试方法:**

    @Test 
    public void testSelectById(){  
            //一个参数   
            Student student = studentDao.selectById(1005);  
            System.out.println("查询 id 是 1005 的学生:"+student); 
    }
    
         <br />