<form action="init1" th:object="${userBean}" method="post">中init1对应的
@RequestMapping(value = "/init1", method = RequestMethod.POST, params = "add");
@RequestMapping(value = "/init1", method = RequestMethod.POST, params = "back")。
其中的"add"和"back"与下面有关
<div>
<span><input type="submit" name="add" value="注册" />
<input type="submit" name="back" value="后退" /></span>
</div>
th:object="${userBean}"中的userBean变量与model.addAttribute("userBean", result1);中的userBean对应。
List<UserBean> result1 = helloWorldService.searchUsers();对应Service中的
public UserBean searchUser2(UserBean frm) {
UserBean result=queryDao.executeForObject("User.selectUser2",frm,UserBean.class);
return result;
}
public List<UserBean> searchUsers() {
List<UserBean> result=queryDao.executeForObjectList("User.selectUsers",null);
return result;
}
//UserBean显示一条,List<UserBean>显示一个列表,selectUser2对应sql文中的
</select>
<select id="selectUser2"
parameterClass="cn.training.bean.UserBean"
resultClass="cn.training.bean.UserBean">
SELECT
userid as userId,
username as userName
FROM
user
WHERE
userid = #userId#
</select>//