📄 faq.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>FileUpload FAQ - FileUpload</title><style type="text/css" media="all"> @import url("./style/maven-base.css"); @import url("./style/maven-theme.css");@import url("./style/project.css");</style><link rel="stylesheet" href="./style/print.css" type="text/css" media="print"></link><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></meta></head><body class="composite"><div id="banner"><a href="http://jakarta.apache.org" id="organizationLogo"><img alt="The Apache Software Foundation" src="http://jakarta.apache.org/images/original-jakarta-logo.gif"></img></a><a href="http://jakarta.apache.org/commons/fileupload/" id="projectLogo"><img alt="FileUpload" src="./images/logo.png"></img></a><div class="clear"><hr></hr></div></div><div id="breadcrumbs"><div class="xleft">Last published: 08 June 2006 <span class="separator">|</span>燚oc for 1.1.1 </div><div class="xright"> <a href="http://jakarta.apache.org/commons/" class="externalLink" title="External Link">Jakarta Commons</a> </div><div class="clear"><hr></hr></div></div><div id="leftColumn"><div id="navcolumn"><div id="menuCommons_FileUpload"><h5>Commons FileUpload</h5><ul><li class="none"><a href="index.html">Overview</a></li><li class="none"><a href="using.html">User guide</a></li><li class="none"><strong><a href="faq.html">FAQ</a></strong></li><li class="none"><a href="apidocs/index.html">Javadoc</a></li><li class="none"><a href="mail-lists.html">Mailing lists</a></li><li class="none"><a href="team-list.html">Team</a></li><li class="none"><a href="tasks.html">Tasks</a></li><li class="none"><a href="cvs-usage.html">SVN repository</a></li></ul></div><div id="menuProject_Documentation"><h5>Project Documentation</h5><ul><li class="none"><a href="index.html">About</a></li><li class="collapsed"><a href="project-info.html">Project Info</a></li><li class="expanded"><a href="maven-reports.html">Project Reports</a><ul><li class="none"><a href="changes-report.html">Changes</a></li><li class="none"><a href="changelog-report.html">Change Log</a></li><li class="none"><a href="checkstyle-report.html">Checkstyle</a></li><li class="none"><a href="developer-activity-report.html">Developer Activity</a></li><li class="none"><strong><a href="faq.html">FAQs</a></strong></li><li class="none"><a href="file-activity-report.html">File Activity</a></li><li class="none"><a href="apidocs/index.html" class="newWindow" title="New Window" target="_blank">JavaDocs</a></li><li class="none"><a href="javadoc.html">JavaDoc Report</a></li><li class="none"><a href="javadoc-warnings-report.html">JavaDoc Warnings Report</a></li><li class="none"><a href="jdepend-report.html">Metrics</a></li><li class="none"><a href="junit-report.html">Unit Tests</a></li><li class="none"><a href="xref/index.html" class="newWindow" title="New Window" target="_blank">Source Xref</a></li><li class="none"><a href="xref-test/index.html" class="newWindow" title="New Window" target="_blank">Test Xref</a></li><li class="none"><a href="license.html">Project License</a></li><li class="none"><a href="pmd-report.html">PMD Report</a></li><li class="none"><a href="simian-report.html">Simian Report</a></li><li class="none"><a href="task-list.html">Task List</a></li></ul></li><li class="none"><a href="http://jakarta.apache.org/commons/charter.html" class="externalLink" title="External Link">Development Process</a></li></ul></div><div id="menuCommons"><h5>Commons</h5><ul><li class="none"><a href="http://jakarta.apache.org/commons/" class="externalLink" title="External Link">Home</a></li><li class="collapsed"><a href="http://jakarta.apache.org/commons/components.html" class="externalLink" title="External Link">Components</a></li><li class="collapsed"><a href="http://jakarta.apache.org/commons/sandbox/index.html" class="externalLink" title="External Link">Sandbox</a></li><li class="collapsed"><a href="http://jakarta.apache.org/commons/dormant/index.html" class="externalLink" title="External Link">Dormant</a></li><li class="none"><a href="http://jakarta.apache.org/commons/volunteering.html" class="externalLink" title="External Link">Volunteering</a></li><li class="none"><a href="http://jakarta.apache.org/commons/patches.html" class="externalLink" title="External Link">Contributing Patches</a></li><li class="none"><a href="http://jakarta.apache.org/commons/building.html" class="externalLink" title="External Link">Building Components</a></li><li class="none"><a href="http://jakarta.apache.org/commons/releases/index.html" class="externalLink" title="External Link">Releasing Components</a></li><li class="none"><a href="http://wiki.apache.org/jakarta-commons/FrontPage" class="externalLink" title="External Link">Wiki</a></li></ul></div><div id="legend"><h5>Legend</h5><ul><li class="externalLink">External Link</li><li class="newWindow">Opens in a new window</li></ul></div><a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy"><img alt="Built by Maven" src="./images/logos/maven-feather.png"></img></a></div></div><div id="bodyColumn"><div class="contentBox"><div class="section"><a name="FileUpload_FAQ"></a><h2>FileUpload FAQ</h2> <p> <strong>General</strong> </p> <ol> <li> <a href="#empty-parse"> Why is parseRequest() returning no items? </a> </li> <li> <a href="#read-timeout"> Why am I getting "Read timed out" exceptions while parsing? </a> </li> <li> <a href="#class-not-found"> Why is NoClassDefFoundError being thrown while parsing? </a> </li> <li> <a href="#whole-path-from-IE"> Why does FileItem.getName() return the whole path, and not just the file name? </a> </li> </ol> <p> <strong>FileUpload and Struts</strong> </p> <ol> <li> <a href="#parse-in-action-fails"> I'm using FileUpload in an Action, but it's not working. Why? </a> </li> <li> <a href="#howto-parse-in-action"> But I need to parse the request myself. How can I do that? </a> </li> </ol> </div><div class="section"><a name="General"></a><h2>General</h2> <title>General</title> <dl> <dt><a name="empty-parse"> Why is parseRequest() returning no items? </a></dt> <dd> This most commonly happens when the request has already been parsed, or processed in some other way. Since the input stream has aleady been consumed by that earlier process, it is no longer available for parsing by Commons FileUpload. </dd> </dl> <dl> <dt><a name="read-timeout"> Why am I getting "Read timed out" exceptions while parsing? </a></dt> <dd> The most common cause of these exceptions is when FileUpload is being used on a site that is using the Tomcat ISAPI redirector. There was a bug in earlier versions of that component that caused problems with multipart requests. The bug was fixed some time ago, so you probably just need to pick up a newer version. See the <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=15278" class="externalLink" title="External Link">Tomcat bug report</a> for full details. </dd> </dl> <dl> <dt><a name="class-not-found"> Why is NoClassDefFoundError being thrown while parsing? </a></dt> <dd> This most commonly happens when attempting to rely on a shared copy of the Commons FileUpload jar file provided by your web container. The solution is to include the FileUpload jar file as part of your own web application, instead of relying on the container. </dd> </dl> <dl> <dt><a name="whole-path-from-IE"> Why does FileItem.getName() return the whole path, and not just the file name? </a></dt> <dd> Internet Explorer provides the entire path to the uploaded file and not just the base file name. Since FileUpload provides exactly what was supplied by the client (browser), you may want to remove this path information in your application. You can do that using the following method from Commons IO (which you already have, since it is used by FileUpload). <pre> String fileName = item.getName(); if (fileName != null) { filename = FilenameUtils.getName(filename); } </pre> </dd> </dl> </div><div class="section"><a name="FileUpload_and_Struts"></a><h2>FileUpload and Struts</h2> <title>FileUpload and Struts</title> <dl> <dt><a name="parse-in-action-fails"> I'm using FileUpload in an Action, but it's not working. Why? </a></dt> <dd> Struts recognises multipart requests, and parses them automatically, presenting the request parameters to your code in the same manner as if they were regular request parameters. Since Struts has already processed the request, and made it available in your form bean, the input stream is no longer available for parsing, so attempting to do so with FileUpload will fail. </dd> </dl> <dl> <dt><a name="howto-parse-in-action"> But I need to parse the request myself. How can I do that? </a></dt> <dd> Struts parses multipart a request as a part of the process of populating your form bean from that request. If, for some reason, you need to have full control over the multipart parsing, you can do so by configuring your action mapping without an associated form bean. (A better way of doing this, however, is to replace the default multipart handler with your own. See the Struts documentation for details.) </dd> </dl> </div></div></div><div class="clear"><hr></hr></div><div id="footer"><div class="xright">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -