读书人

DispatchAction的施用

发布时间: 2012-11-01 11:11:33 作者: rapoo

DispatchAction的使用

??? ??? <table width="90%" border="1" align="center" bordercolor="#CCCCCC">
??? ??? ??? ??? <tr>
??? ??? ??? ??? <input type="hidden" name="method" value="save"/>//该隐藏域的method属性的值就是ListAllLeavesAction类对应的save方法的名字
??? ??? ??? ??? ??? <td width="100" align="right" type="text">
??? ??? ??? ??? ?  </td>
??? ??? ??? ??? ??? <td width="98" align="right" type="text"> </td>
??? ??? ??? ??? </tr>

??? ??? ??? ??? <tr>
??? ??? ??? ??? ??? <td align="right" type="text"></td>
??? ??? ??? ??? ??? <td align="right" type="text"></TD>
??? ??? ??? ??? </tr>
??? ??? ??? ??? <tr align="center">
??? ??? ??? ??? ??? <td height="33" colspan="5">
??? ??? ??? ??? ??? ??? <input type="button" value="确定" onClick="submit();" />
??? ??? ??? ??? </td>
??? ??? ??? ??? </tr>
??? ??? </table>
??? </html:form>???
??? </body>
</html>
这样就会调用ListAllLeavesAction类里面的save方法

4.Struts配置文件的配置
<struts-config>
??? <form-beans>
??? ??? <form-bean name="addLybForm" type="com.dragonsoft.lyb.struts.form.LybanForm" />
??? </form-beans>

??? <action-mappings>
??? <action attribute="addLybForm" parameter="method" input="/jsp/addLyban.jsp"? name="addLybForm" path="/jsp/lyb/manageLyban" scope="request" type="com.dragonsoft.lyb.struts.action.ListAllLeavesAction">
??? ??? <forward name="success" path="/jsp/lyb/manageLyban.do?method=list"/>
??? ??? <forward name="list" path="/jsp/listAllLeaves.jsp" />
??? </action>
??? </action-mappings>
</struts-config>
注意的是parameter的值要跟页面隐藏域method的名字一样

这是一个简单的例子,想必大家也看的懂,我就不需要再罗嗦了。

读书人网 >软件架构设计

热点推荐