java Struts 多种表单写法
1.html:form(struts标签)
缺点:必须指定一个有效的action属性。
优点:可以使用struts token机制。
调用方法通过submit的name属性。
1 <table align="center" class="TableBGColor" width="400" border="0" cellSpacing=1 cellPadding=5 height="200"> 2 <html:form action="organAction" method="post" styleId="organForm"> 3 <html:hidden property="pkid" /> 4 <html:hidden property="super_id" /> 5 <c:set var="pageButtons"> 6 <tr align="center" class="BtnBgColor" height="18"> 7 <td class="TdBGColor1" align="right"></td> 8 <td class="buttonBar" align="left"> 9 <input name="method.save" type="submit" value="<fmt:message key="button.save" />" style="width:60;" onClick="return validate();"> 10 <input name="method.list" type="submit" value="<fmt:message key="button.cancel" />" style="width:60;" onClick="bCancel=true"> 11 </td> 12 </tr> 13 </c:set> 14 <br> 15 ---表单内容--- 16 17 <c:out value="${pageButtons}" escapeXml="false" /> 18 </html:form>
2.form(html标签)
优点:action定义灵活,可以用JS随意改变action属性
缺点:不能方便的使用token。
调用方法写在Action.do?后面
1 <form name="replysForm" 2 action="<%=request.getContextPath()%>/msgreplyqueryAction.do?method=listMsgReplys" 3 method="post"> 4 <table border="0" width="100%" align="left" cellSpacing=0 5 cellPadding=0> 6 <tr> 7 <td width="10%" height="30" align="left" nowrap><fmt:message 8 key="message.title.phone" /> <input type="text" 9 name="phoneNo" value="<c:out value="${phoneNo}" />" /></td> 10 <td width="100%" height="30" align="left" nowrap> 11 <fmt:message key="message.title.date" /> <c:if 12 test="${sendDate ==null}"> 13 <html:text property="date" styleId="date" readonly="true" 14 value="<%=date%>" style="width:240;" /> 15 </c:if> <c:if test="${sendDate !=null}"> 16 <html:text property="date" styleId="date" readonly="true" 17 value="<%=sendDate%>" style="width:240;" /> 18 </c:if> <input name="findreplys" type="submit" 19 value="<fmt:message key="message.button.query"/>"> 20 </td> 21 </tr> 22 </table> 23 </form>

浙公网安备 33010602011771号