Action execute()没有执行怎么不通过Form来调用它
我页面要显示数据库信息
我jsp页面
HTML code
<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>