2008-05-13
ActionFrom和request请求页面属性的区别
今天在研究ActionFrom和request请求页面属性的区别, 今日出现这样的问题让我很难以理解:
在我的Action里请求页面属性值,有的用ActionForm请求能得到,有的用request请求能得到,不知道为什么!
这个是我的页面属性值:
<form name="form1" method="post" action="<%=url%>?method=updateOtherPId&backUrl=${pageContext.request.contextPath}/service/search_InsurancePID.jsp" onsubmit="submitForm2()">
<table width="70%" border="0" align="center">
<tr height="28">
<td align="center" width="13%">投保人:
<input type="hidden" name="tmp" id="tmp" value="<%=tmp%>"/>
<input type="hidden" name="pId" id="pId" value="<%=pId%>"/></td>
<td>
<input type="text" name="ph" id="ph" size="30" readOnly value="<%=ph%>"/>
<input type="hidden" name="backUrl" value="${pageContext.request.requestURL}?${pageContext.request.queryString}" />
<input type="hidden" name="backParam" value="" />
<input type="hidden" name="status" value="1" />
<input type="hidden" name="action" value="add" />
</td>
</tr>
<tr height="28">
<td align="center" width="13%">更改为:</td>
<td>
<input type="text" name="phtmp" id="phtmp" size="30" value=""/>
</td>
</tr>
<tr>
<td align="center" width="13%"> </td>
<td align="left" style="right:30xp">
<input type="button" class="clsBtn2w" name="btn1" value="修改" onclick="submitForm2();"/>
<input type="button" name="btn1" class="clsBtn2w" value="取消" onclick="javascript:history.go(-1)"/>
</td>
</tr>
</table>
</form>
<input type="hidden" name="pId" id="pId" value="<%=pId%>"/>这个隐藏域里的pId 在action里用ActionFrom得不到,当然我的ActionFrom也定义了pId的属性.但不知是为什么.
在action里呢:
String pId = request.getParameter("pId");
String phtmp = questionForm.getPhtmp();
int infoType = questionForm.getInfoType();
下面两项用ActionFrom就能得到其属性值, 上面的那个就要用request来得到.
今天研究到这里,差不多快研究懂了.等研究懂后发布出来和大家一起欣赏.
当然如果有对ActionFrom和request请求页面属性的区别理解深刻的同志,希望能不吝赐教.
在我的Action里请求页面属性值,有的用ActionForm请求能得到,有的用request请求能得到,不知道为什么!
这个是我的页面属性值:
<form name="form1" method="post" action="<%=url%>?method=updateOtherPId&backUrl=${pageContext.request.contextPath}/service/search_InsurancePID.jsp" onsubmit="submitForm2()">
<table width="70%" border="0" align="center">
<tr height="28">
<td align="center" width="13%">投保人:
<input type="hidden" name="tmp" id="tmp" value="<%=tmp%>"/>
<input type="hidden" name="pId" id="pId" value="<%=pId%>"/></td>
<td>
<input type="text" name="ph" id="ph" size="30" readOnly value="<%=ph%>"/>
<input type="hidden" name="backUrl" value="${pageContext.request.requestURL}?${pageContext.request.queryString}" />
<input type="hidden" name="backParam" value="" />
<input type="hidden" name="status" value="1" />
<input type="hidden" name="action" value="add" />
</td>
</tr>
<tr height="28">
<td align="center" width="13%">更改为:</td>
<td>
<input type="text" name="phtmp" id="phtmp" size="30" value=""/>
</td>
</tr>
<tr>
<td align="center" width="13%"> </td>
<td align="left" style="right:30xp">
<input type="button" class="clsBtn2w" name="btn1" value="修改" onclick="submitForm2();"/>
<input type="button" name="btn1" class="clsBtn2w" value="取消" onclick="javascript:history.go(-1)"/>
</td>
</tr>
</table>
</form>
<input type="hidden" name="pId" id="pId" value="<%=pId%>"/>这个隐藏域里的pId 在action里用ActionFrom得不到,当然我的ActionFrom也定义了pId的属性.但不知是为什么.
在action里呢:
String pId = request.getParameter("pId");
String phtmp = questionForm.getPhtmp();
int infoType = questionForm.getInfoType();
下面两项用ActionFrom就能得到其属性值, 上面的那个就要用request来得到.
今天研究到这里,差不多快研究懂了.等研究懂后发布出来和大家一起欣赏.
当然如果有对ActionFrom和request请求页面属性的区别理解深刻的同志,希望能不吝赐教.
评论
Angelialily
2008-05-13
谢谢你的不吝赐教,我测试了.的确如此,新手上道以后还望多多指导!
tianzhihua
2008-05-13
pId命名struts不支持,Id前面必须有2个以上的小写单词
发表评论
提醒: 该博客已发表在公共论坛,博客所有留言会成为论坛回贴,留言请注意遵守论坛发贴规则
- 浏览: 5502 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
足球比赛用语
不错,看欧洲杯,学英语
-- by ispring -
js窗口&提示大全
不错的积累
-- by zzg810314 -
在线购物系统毕业论文 & ...
帮忙发给我一份,谢谢!! winyou2008@hotmail.com
-- by winyou365 -
用DOS命令给文件夹加密
Windows 文件系统 (NTFS)支持的某些文件命名格式,不知道为什么exp ...
-- by greens.leaf -
用DOS命令给文件夹加密
呵....很不错...
-- by zhouzhao21






评论排行榜