package com.sly.web.sys.model;
public class SysU {
private int id;
private String username;
private String sex;
private String birthday;
private String address;
private Tone t1;
private Ttwo t2;
省略getter setter
}
controller!!!!!!!!
@RequestMapping(value="testParamModel01" , method = RequestMethod.GET)
public void testParamModel(){
Tone t1 = new Tone();
t1.setAdd("address1");
t1.setPhone("phone");
Ttwo t2 = new Ttwo();
t2.setAge("age");
t2.setSex("sex");
SysU s = new SysU();
s.setT1(t1);
s.setT2(t2);
s.setUsername("username");
List<String> l = sysService.testRun07(s);
}
service !!!!!!!!!
public List<String> testRun07(SysU s){
List<String> l = sysUMapper.testParamModel2(s);
return l;
}
mapper.java
public List<String> testParamModel2(@Param("sysu") SysU sysu);
mapper.xml
<select id="testParamModel2" resultType="java.lang.String">
select username from testuser
<where>
address = #{sysu.t1.add}
</where>
</select>
注意 获取的 t1 与 add 分别为 对象中成员变量的名字 通过 getter方法名字来获取数值