Struts1.x的三种action的比较(笔记)

 

 

dispatchAction

dispatchAtion

mappingDispatchAction

DispatchAction

resetAction

action

 

 

 

提交不同参数的action

 

Jsp页面

<a href="

testDispatch.do

?methodName=add">分发的Action_添加</a>

<a href="testMapping_add.do">

MappingDispatchAction_添加</a>

<a href="testReset.do

?task=delete&userid=1">删除的操作</a>

 

struts-config.xml

action中加入

parameter="methodname"

每个不同的参数都对应一个action,并且对应action要设置parameter的值,path也要修改:

path="/testMapping_add"

      parameter="add"

 

 

不做特别的修改

 

Action

execute改为目标方法如此处的add

execute改为目标方法如此处的add

接收的action都在execute执行,通过task接收的不同参数而分别执行

 

ActionForm

 

 

设置task属性

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1.  通过加载Strut1.3框架

2.    通过new —>other àwebStruts新建所需要的actionFormactionjsp页面

3. 注意点:

A.建action:input这个参数是指actionFormvalidate验证失败标志时所应该转向的页面

B.建Forward:succaction中执行成功时的标识,由execute中的mapping通过findForward方法找到这个succ标识所指向的页面success.jsp,从而实现成功页面的跳转

C.在jsp页面中通过form标识提交的时候,action的值要与Struts-congfig.xml中的path一致

D.JSP页面中使用ActionForm标签

   首先,导入标签库

<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>

<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>

<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

   然后,编写jsp页面

<!--show the error message of actionForm-->

<!-- 本页面的action的值要与对应的struts-config.xml中的actionPath值一致 -->

<html:form action="/testResetaction" style="form1">

 textfield:<html:text property="username"></html:text><font color="red"><html:errors property="空信息"/></font>

<!-- 这里的errors property的值应设为对应的actionFormActionError添加时设置的错误名称 -->

 <br><br>

 <br><br>

 sex:

<!-- 本页面的property的值要与对应的actonForm中的属性名称一致 -->

 <html:radio property="usersex" value="1">Nan</html:radio>

 <html:radio property="usersex" value="0">Nv</html:radio>

 <br><br>

 <html:submit value="submit"></html:submit>

</html:form>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值