我使用struts1.2来做一个网站,首页index.html包括两个表单form1,form2,表单的属性如下:
<form id="form1" name="form1" method="post" action="index-1.do">
<form id="form2" name="form2" method="post" action="index-2.do">
一次只提交一个表单的数据,struts-config.xml文件配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
  <data-sources />
  <form-beans>
  <form-bean name="cheCiForm" type="wind.CheCiForm"/>
  </form-beans>
  <global-exceptions />
  <global-forwards />
  <action-mappings>
  <action path="/pages/index" type="wind.CheCiAction" name="cheCiForm" scope="request" >
  <forward name="cc_success" path="/pages/cc_result.jsp" redirect="true"/>
  <forward name="cc_faild" path="/pages/cc_result.jsp" redirect="true"/>
  </action>
  </action-mappings>
 </struts-config>
我把所有页面文件都放在"WEB-ROOT/pages/"路径下的,我预想的流程是:登录index.html页面,选择任意一个表单输入数据,提交之后通过action拦截index.do然后根据查询的结果重定向到cc_result.jsp页面来显示查询的结果,现在就是在index.html提交数据之后出现如下错误:
HTTP Status 404 - Invalid path /pages/index was requested--------------------------------------------------------------------------------type Status reportmessage Invalid path /pages/index was requesteddescription The requested resource (Invalid path /pages/index was requested) is not available.无论我怎么改struts-config.xml中action的path属性都始终报这个错,我尝试把index.html和cc_result.jsp两个页面放到WEB-ROOT根路径但是无法实现重定向,页面地址停留在index.do上,我配置redirect="true"应该会重定向到cc_result.jps上的嘛,希望大家帮我看看,谢谢!

解决方案 »

  1.   

    <form id="form1" name="form1" method="post" action="index-1.do">改为
    <html:form action="pages/index">我忘记是不是 /pages/indexstruts 是根据你form中的action来找 struts_config.xml文件中的path
      

  2.   

    再根据 path  对应的type来找action 和form
      

  3.   

    <form id="form1" name="form1" method="post" action="index-1.do">
                                                             ↑
    你的xml文件中的path="/page/index"有问题,可否这样写path="index-1"你看一下这个配置:
    <action attribute="ArchivesFlowCouser" name="archivesFlowCouser"
    parameter="method" path="/displayFlowCouser"
    input="/archivesSaveFlowCouserTemplet.jsp" scope="request"
    type="com.oa.struts.action.FlowCouserAction">
    <forward name="archivesSaveFlowCouserTemplet"
    path="/archivesSaveFlowCouserTemplet.jsp" />
    </action>
    只是做参照。有不明白在问吧!