当前位置: 代码迷 >> Java Web开发 >> Struts中ActionForm转换的有关问题
  详细解决方案

Struts中ActionForm转换的有关问题

热度:4384   发布时间:2013-02-25 21:09:17.0
Struts中ActionForm转换的问题
代码如下:
  
主界面对应的类在配置文件中如下:
<action path="/DiseaseInfo/PatientBaseInfo"
type="com.gzq.struts.action.PatientBaseInfoAction"
name="PatientBaseInfoForm"
scope="request"
parameter="command">

在主界面中添加的超级链接具体如下:
<td>
  html:link href="../DiseaseInfo/baseinfo.do?command=PatReport" paramId="ComId" paramName="ele" paramProperty="comId">上报</html:link>
</td>


DiseaseInfo/baseinfo.do对应的配置文件如下:
<action path="/DiseaseInfo/baseinfo"
type="com.gzq.struts.action.BaseInforAction"
name="InputCPWayPatientForm"
scope="request"
parameter="command">
<forward name="NewPatientPage" path="/DiseaseInfo/NewPatientPage.jsp"/>


com.gzq.struts.action.BaseInforAction中PatReport代码如下:
public ActionForward PatReport(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

  ..............略................
return mapping.findForward("NewPatientPage");

调试发现 PatReport中form对应的是InputCPWayPatientForm,但是在NewPatientPage.jsp中绑定的formbean提示却是PatientBaseInfoAction。很疑惑,不清楚为什么?难道这是Struts架构就这样的吗?我有什么办法让InputCPWayPatientForm与页面NewPatientPage.jsp进行数据绑定?请各位不吝赐教,在线等待。


------解决方案--------------------------------------------------------
建议使用struts2!
------解决方案--------------------------------------------------------
还是用struts2把 struts1太麻烦了
------解决方案--------------------------------------------------------
探讨
谢谢回复,但是目前已经做了大半的工作了,积重难返了,我想知道上述的现象Struts就这样设计的?有没有办法处理我目前的问题,我尝试过:
ActionForward af= mapping.findForward("NewPatientPage"); af.setRedirect(true);
return af;
但是还是不行,是否可以想办法在通过修改af的属性指定其绑定的formbea……

------解决方案--------------------------------------------------------
探讨

这下迷迷糊糊看懂了
但是response到页面(NewPatientPage.jsp)的时候提示的却是PatientBaseInfoForm
楼主是指 response.sendRedirect();吗?

页面与formbean的绑定是 和form的action想对象的

楼主把NewPatientPage.jsp 代码贴一下
  相关解决方案