关于点击姓名无法跳转修改页面的wenti
struts.xml
<struts> <package name="default" namespace="/" extends="struts-default" strict-method-invocation="false"> <global-allowed-methods>regex:.*</global-allowed-methods> </package> <package name="users" namespace="/users" extends="default"> <action name="*_*" class="action.{1}Action" method="{2}"> <result name="login_success">/users/Users_login_success.jsp</result> <result name="login_failure">/users/Users_login.jsp</result> <result name="logout_success">/users/Users_login.jsp</result> <result name="input">/users/Users_login.jsp</result> </action> </package> <package name="students" namespace="/students" extends="default"> <action name="*_*" class="action.{1}Action" method="{2}"> <result name="query_success">/students/Students_query_success.jsp</result> <result name="delete_success" type="chain">Students_query</result> <result name="add_success">/students/Students_add_success.jsp</result> <result name="modify_success">/students/Students_modify.jsp</result> </action> </package> </struts>
action
// 修改学生信息 public String modify() { // 获得传过来的学生id String sid = request.getParameter("sid"); StudentsDAO sdao = new StudentsDAOimpl(); Students s = sdao.queryStudentsBySid(sid); // 保存在session中 session.setAttribute("modify_students", s); //String address = request.getParameter("address"); //String sname = request.getParameter("sname"); //String gender = request.getParameter("gender"); //String birthday = request.getParameter("birthday"); //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //// Students s = new Students(); // s.setSid(sid); // s.setBirthday(sdf.parse(birthday)); // s.setAddress(address); // s.setSname(sname); // s.setGender(gender); return "modify_succcess"; }
modify.jsp
<div id="mainContainer"> <!-- 从session中获取学生集合 --> <strong>修改学生资料</strong> <br> <br> <form name="modifyForm" action="<%=path%>/students/Students_modify.action" method="post"> <table width="400" > <tr> <td width="30%">学号:</td> <td><input type="text" name="sid" value='<s:property value="#session.modify_students.sid"/>' readonly="readonly"/></td> </tr> <tr> <td width="30%">姓名:</td> <td><input type="text" name="sname" value='<s:property value="#session.modify_students.sname"/>'/></td> </tr> <tr> <td>性别:</td> <td> <s:if test='%{#session.modify_students.gender=="男"}'> <input type="radio" name="gender" value="男" checked="checked"/>男 <input type="radio" name="gender" value="女"/>女 </s:if> <s:else> <input type="radio" name="gender" value="男" />男 <input type="radio" name="gender" value="女" checked="checked"/>女 </s:else> </td> </tr> <tr> <td>出生日期:</td> <td><input name="birthday" type="text" id="control_date" size="20" maxlength="10" onclick="new Calendar().show(this);" readonly="readonly" value="<s:date name="#session.modify_students.birthday" format="yyyy-MM-dd"/>" /> </td> </tr> <tr> <td>地址:</td> <td><input type="text" name="address" value='<s:property value="#session.modify_students.address"/>'/></td> </tr> <tr> <td colspan="2" align="center"> <input class="button" type="submit" value="修改"></td> </tr> </table> </form> </div>