<%@page contentType="text/html;charset=gbk" %>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<h3 align="center">Dispatch Action</h3>
<hr>
<pre>
根据请求中的某个(1)参数的值来调用Action的方法(2)。
(1)参数名字在<action parameter="method" />
(2)方法名字为 method 参数的值。
</pre>
<center>
<a href="${pageContext.request.contextPath}/dispatch.do?method=login">login</a>
<a href="${pageContext.request.contextPath}/dispatch.do?method=find">find</a>
<a href="${pageContext.request.contextPath}/dispatch.do?method=findById">findById</a>
<a href="${pageContext.request.contextPath}/dispatch.do?method=register">register</a>
<a href="${pageContext.request.contextPath}/dispatch.do?method=remove">remove</a>
<a href="${pageContext.request.contextPath}/dispatch.do?method=modify">modify</a>
</center>
<hr>
<h3 align="center">LookupDispatch Action</h3>
<hr>
<pre>
</pre>
<center>
<form method="post" action="${pageContext.request.contextPath}/lookup.do">
<input type="submit" value="<bean:message key="submit.login"/>" name="method">
<input type="submit" value="<bean:message key="submit.find"/>" name="method">
<input type="submit" value="<bean:message key="submit.findById"/>" name="method">
<input type="submit" value="<bean:message key="submit.register"/>" name="method">
<input type="submit" value="<bean:message key="submit.remove"/>" name="method">
<input type="submit" value="<bean:message key="submit.modify"/>" name="method">
</form>
</center>
<!--
<h3 align="center">LookupDispatch Action</h3>
<hr>
<pre>
</pre>
<center>
<form method="post" action="${pageContext.request.contextPath}/lookup.do">
<input type="hidden" name="method" value="login">
<input type="submit" value="login" name="m" onclick="this.form.method.value='login'">
<input type="submit" value="find" name="m" onclick="this.form.method.value='find'">
<input type="submit" value="findById" name="m" onclick="this.form.method.value='findById'">
<input type="submit" value="register" name="m" onclick="this.form.method.value='register'">
<input type="submit" value="remove" name="m" onclick="this.form.method.value='remove'">
<input type="submit" value="modify" name="m" onclick="this.form.method.value='modify'">
</form>
</center>
-->
<hr>
<h3 align="center">MappingDispatch Action</h3>
<hr>
<pre>
根据<action>标记的parameter属性的值来调用Action的方法(1)。
(1)方法名字为 parameter属性的值。
</pre>
<center>
<a href="${pageContext.request.contextPath}/mapping/login.do">login</a>
<a href="${pageContext.request.contextPath}/mapping/find.do">find</a>
<a href="${pageContext.request.contextPath}/mapping/findById.do?id=1">findById</a>
<a href="${pageContext.request.contextPath}/mapping/register.do">register</a>
<a href="${pageContext.request.contextPath}/mapping/remove.do?id=2">remove</a>
<a href="${pageContext.request.contextPath}/mapping/modify.do">modify</a>
</center>
=====================================================
<?xml version="1.0" encoding="gb2312" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="loginForm" type="com.allanlxf.action.LoginForm"/>
<form-bean name="userForm" type="org.apache.struts.action.DynaActionForm">
<form-property name="userName" type="java.lang.String" />
<form-property name="password" type="java.lang.String" />
</form-bean>
</form-beans>
<action-mappings>
<action path="/core/login" type="com.allanlxf.action.LoginAction"
name="loginForm" input="/core/login.jsp" validate="true" scope="request">
<exception key="errors.root"
path="/core/error.jsp"
type="com.allanlxf.biz.IllegalUserException" />
<forward name="success" path="/core/success.jsp" redirect="true"/>
<forward name="fail" path="/core/fail.jsp" />
</action>
<action path="/dispatch" type="com.allanlxf.struts.actions.UserAction" parameter="method">
<forward name="login" path="/actions/pages/login_next.jsp" />
<forward name="find" path="/actions/pages/find_next.jsp" />
<forward name="findById" path="/actions/pages/findById_next.jsp" />
<forward name="remove" path="/actions/pages/remove_next.jsp" />
<forward name="modify" path="/actions/pages/modify_next.jsp" />
<forward name="register" path="/actions/pages/register_next.jsp" />
</action>
<action path="/mapping/login" type="com.allanlxf.struts.actions.UserMappingAction" parameter="login">
<forward name="next" path="/actions/pages/login_next.jsp" />
</action>
<action path="/mapping/find" type="com.allanlxf.struts.actions.UserMappingAction" parameter="find">
<forward name="next" path="/actions/pages/find_next.jsp" />
</action>
<action path="/mapping/findById" type="com.allanlxf.struts.actions.UserMappingAction" parameter="findById">
<forward name="next" path="/actions/pages/findById_next.jsp" />
</action>
<action path="/mapping/remove" type="com.allanlxf.struts.actions.UserMappingAction" parameter="remove">
<forward name="next" path="/actions/pages/remove_next.jsp" />
</action>
<action path="/mapping/modify" type="com.allanlxf.struts.actions.UserMappingAction" parameter="modify">
<forward name="next" path="/actions/pages/modify_next.jsp" />
</action>
<action path="/mapping/register" type="com.allanlxf.struts.actions.UserMappingAction" parameter="register">
<forward name="next" path="/actions/pages/register_next.jsp" />
</action>
<action path="/lookup" type="com.allanlxf.struts.actions.UserLookupAction" parameter="method">
<forward name="login" path="/actions/pages/login_next.jsp" />
<forward name="find" path="/actions/pages/find_next.jsp" />
<forward name="findById" path="/actions/pages/findById_next.jsp" />
<forward name="remove" path="/actions/pages/remove_next.jsp" />
<forward name="modify" path="/actions/pages/modify_next.jsp" />
<forward name="register" path="/actions/pages/register_next.jsp" />
</action>
<action path="/dyna/register" type="com.allanlxf.action.RegisterAction"
name="userForm">
<forward name="success" path="/dyna/success.jsp"/>
</action>
</action-mappings>
<message-resources parameter="com.allanlxf.MessageResources" />
</struts-config>
posted on 2007-04-25 16:12
sunny 阅读(652)
评论(0) 编辑 收藏