在struts-config.xml中每个对应的action有一个对应的actionform
是这样对应的

解决方案 »

  1.   

    ActionForm就是一个Bean,一般在.xml文件中配置,但JSP中也不是只能用.xml文件中配置了的Bean,就象一个普通的JSP文件一样,可用到其它的Bean,它主要就是用于保存数据。在Struts中也可以用非ActionForm扩展的Bean.只是不能用到ActionForm的一些特性,如数据验证,出错处理等.
      

  2.   

    http://www.ninsky.com/struts/index.html上面例子里的源代码相信说得很清楚
      

  3.   

    但是struts-config.xml中这么多BEAN怎么确实这JSP页面与哪个BEAN作互映射呢
      

  4.   

    Struts是这样认为的:如果一个JSP页面里有Form元素,就认为这个Form元素对应着一个JAVABEAN,这个JAVABEAN在Struts中叫做FormBean,关于如何对应,就是在struts-config.xml中设置了,一个Formbean的名字对应一个javabean类(FormBean),用标签引用<html:form property=FormBean名字>这样就对应起来了
      

  5.   

    <html:form name="fileForm" type="origin.weather.actionform.FileForm" method="post" action="fileSearchAction.do" onsubmit="return validateFileForm(this);">
      

  6.   

    再jsp文件中:又一句
    <html:form action="insertAdmin" focus="name" method="post">在struts-config.xml中,相应的有配置:
    <form-beans>
       <form-bean name="adminUserForm" type="xxxxx.struts.AdminActionForm" />/////////////这里保存adminUserForm的绝对路径,通过这个得到form的路径
    </form-beans>
    <action path="/insertAdmin" type="xxxxx.struts.AdminAction" name="adminUserForm" scope="request">
        <forward name="success" path="/do/listAllAdmins"/>
    </action>在这个.xml文件中,type的值就是这个insertAdmin(映射)的绝对路径,name的值就是ActionForm,保存页面from要提交处理的所有信息
      

  7.   

    是通过<html:form>这个标签来映射的。这个标签又一个action属性,通过这个action属性到struts-config的action-mappings里面找到相应的action的。而action-mappings里面定义的action都有name这个属性的,这个就是关联到具体的ActionForm的。