日期:2014-05-18 浏览次数:20780 次
<table> <tr> <td>真实姓名:</td> <td>用户权限:</td> <td>所在部门:</td> </tr> <c:forEach items="aa" var="user"> <tr> <td>${user.usertruename}</td> <td>${user.userable}</td> <td>${user.userbranch}</td> <td>${user.useremail}</td> </tr> </c:forEach> </table>
Java codepublic ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws InstantiationException, IllegalAccessException, SQLException { String username="liukai"; System.out.print(username); List users = new ArrayList(); DB db = new DB(); String sql="select user_password,user_truename,user_useable,user_branch, user_email from "+Content.TB_USER+" where "+Content.USERNAME+"='"+username+"'"; ResultSet rs=(ResultSet) db.getRs(sql); while(rs.next()){ UserForm user = new UserForm(); user.setUsertruename(rs.getString("user_truename")); user.setUserable(rs.getInt("user_useable")); user.setUserbranch(rs.getString("user_branch")); user.setUseremail(rs.getString("user_email")); users.add(user); } request.setAttribute("aa",users); System.out.print(users); return mapping.findForward("success"); }
<action name="UserForm" path="/test" scope="request" validate="false" type="com.liukai.struts.action.TestAction"> <forward name="success" path="MyTest.jsp" /> </action>