I have a submit button in A.jsp,and I want to submit to B.do from A.jsp,but
when I click this submit button,it should submit to B.do and show some
information on screen,but in fact it doesn't work,when I use
http://localhost:8080/B.do, it can work.I don't know why it don't work from
A.jsp to B.do?
My code is follows:
/*A.jsp*/
<%@ taglib uri="/WEB-INF/taglib/struts-html" prefix="html"%>
<html:form action="/B.do" method="post" enctype="multipart/form-data">
<html:file property="attachFile" />
<input type="submit" name="Submit2" value="OK" />
</html:form>

/*AForm.java*/
package test;
import org.apache.struts.action.ActionForm;
public class AForm extends ActionForm{
}

/*AAction.java*/
package test;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class AAction extends Action{
 public ActionForward execute(ActionMapping mapping,ActionForm
form,HttpServletRequest req,HttpServletResponse res){
  System.out.println("A action");
  return mapping.findForward("B");
 }
}

/*B.jsp*/
<html>
<body>
Hello world
</body>
</html>

/*BForm.java*/
package test;
import org.apache.struts.action.ActionForm;
import org.apache.struts.upload.FormFile;
public class BForm extends ActionForm{
   protected FormFile attachFile;
   public FormFile getAttachFile(){
     return attachFile;
  }
  public void setAttachFile(FormFile attachFile){
  this.attachFile=attachFile;
 }

/*BAction.java*/
package test;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
public class BAction extends Action{
 public ActionForward execute(ActionMapping mapping,ActionForm
form,HttpServletRequest req,HttpServletResponse res){
  System.out.println("B action");
  return mapping.findForward("B");
}

/*struts-config.xml*/
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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>
    <form-beans>
    <form-bean name="AForm" type="test.AForm" />
    <form-bean name="BForm" type="test.BForm" />
 </form-beans>

 <action-mappings>
  <action path="/A" type="test.AAction" scope="session" validate="true"
input="/A.jsp">
      <forward name="A" path="/A.jsp"/>
      <forward name="B" path="/B.jsp"/>
  </action>
  <action path="/B" type="test.BAction" name="BForm" scope="request"
validate="true">
     <forward name="B" path="/B.jsp"/>
  </action>

 </struts-config>

Reply via email to