1、list导入的包是 java.util.list;
页面输出引用一个标签<C:foreach></c:foreach>
1、在UserSqlMap中键入关键代码:
<select id="selectUser"
parameterClass="cn.training.bean.UserBean"
resultClass="cn.training.bean.UserBean">
SELECT
userid as userId,
username as userNam
FROM
user “用列表显示所有的bean语句不用条件 ”
</select>
2、在HelloWorldService中键入关键代码
public List<UserBean> searchUser(UserBean frm) {
List<UserBean> result = queryDao.executeForObjectList("User.selectUser", frm);
return result;
3、在HelloWorldController中键入关键代码:
@RequestMapping(value = "/init", method = RequestMethod.POST)
public String initLogin(UserBean userBean, Model model) {
List<UserBean> result = helloWorldService.searchUser(userBean);
model.addAttribute("list", result);
return "login";
4、在login.jsp中
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:forEach items="${list}" var="user" varStatus="status">
${user.userId}
${user.userName}
</c:forEach>