我想你的jsp一定有
<html:form action="upload.do">看看你struts-config.xml文件中,是否有
  <action-mappings>
    <action    path="/upload"
               type="org.apache.struts.webapp.upload.UploadAction"
               name="uploadForm">
        <forward name="display" path="/display.jsp" />
   </action>
path 对应你form提交的do,
type 对应action的位置
name 对应actionform的位置
forward 对应迁移画面的名称,
你的错误是找不到,upload
Cannot retrieve mapping for action /upload

解决方案 »

  1.   

    这些都是在jb8里做的,要做的都有了
    但第一个问题的是经常出现的:
    java.lang.IllegalArgumentException: argument type mismatch
    ......
    这又何解?
      

  2.   

    jsp页面:
    <%@ page import="org.apache.struts.action.*,
                     java.util.Iterator,
                     test.T5ActionForm"%>
    <%@ page language="java" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <head>
    <title>
    t5
    </title>
    </head>
    <body><html:form action="/t5Action.do"  enctype="multipart/form-data">
    file:<html:file property="thefile"/><br><html:submit /></html:form>
    </body>
    </html:html>form bean:
    package test;import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.upload.DiskFile;
    import org.apache.struts.*;
    import org.apache.struts.upload.MultipartRequestHandler;import javax.servlet.http.*;
    public class T5ActionForm extends ActionForm {
      private DiskFile thefile;
      private java.sql.Date dd;
      public void setThefile(DiskFile thefile) {
        this.thefile = thefile;
      }
      public DiskFile getThefile() {
        return thefile;
      }
      public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
        /**@todo: finish this method, this is just the skeleton.*/
        return null;
      }
      public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
      }
    }Action:
    package test;
    import org.apache.struts.upload.DiskFile;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ForwardingActionForward;import javax.servlet.http.*;public class T5Action extends Action {
      public ActionForward perform(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) {
        /**@todo: complete the business logic here, this is just a skeleton.*/    String encoding = httpServletRequest.getCharacterEncoding();
        if ((encoding != null) && (encoding.equalsIgnoreCase("utf-8")))
        {
           httpServletResponse.setContentType("text/html; charset=utf-8");
        }
        T5ActionForm f = (T5ActionForm) actionForm;
        DiskFile file = f.getThefile();
        //String filepath = file.getFilePath();
        String filename = file.getFileName();
         String contentType = file.getContentType();
         httpServletRequest.setAttribute("filename",filename);
          return (actionMapping.findForward("out"));  }
    }