亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? commonsmultipartrequesthandler.java

?? 這是STRUTS1.2。6的開發包。。這是我從芝APACHE網站下下來
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * $Id: CommonsMultipartRequestHandler.java 54929 2004-10-16 16:38:42Z germuska $ 
 *
 * Copyright 1999-2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


package org.apache.struts.upload;


import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.DiskFileUpload;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.config.ModuleConfig;
import org.apache.struts.Globals;


 /**
  * This class implements the <code>MultipartRequestHandler</code> interface
  * by providing a wrapper around the Jakarta Commons FileUpload library.
  *
  * @version $Rev: 54929 $ $Date: 2004-10-16 09:38:42 -0700 (Sat, 16 Oct 2004) $
  * @since Struts 1.1
  */
public class CommonsMultipartRequestHandler implements MultipartRequestHandler {


    // ----------------------------------------------------- Manifest Constants


    /**
     * The default value for the maximum allowable size, in bytes, of an
     * uploaded file. The value is equivalent to 250MB.
     */
    public static final long DEFAULT_SIZE_MAX = 250 * 1024 * 1024;


    /**
     * The default value for the threshold which determines whether an uploaded
     * file will be written to disk or cached in memory. The value is equivalent
     * to 250KB.
     */
    public static final int DEFAULT_SIZE_THRESHOLD = 256 * 1024;


    // ----------------------------------------------------- Instance Variables


    /**
     * Commons Logging instance.
     */
    protected static Log log = LogFactory.getLog(
            CommonsMultipartRequestHandler.class);


    /**
     * The combined text and file request parameters.
     */
    private Hashtable elementsAll;


    /**
     * The file request parameters.
     */
    private Hashtable elementsFile;


    /**
     * The text request parameters.
     */
    private Hashtable elementsText;


    /**
     * The action mapping  with which this handler is associated.
     */
    private ActionMapping mapping;


    /**
     * The servlet with which this handler is associated.
     */
    private ActionServlet servlet;


    // ---------------------------------------- MultipartRequestHandler Methods


    /**
     * Retrieves the servlet with which this handler is associated.
     *
     * @return The associated servlet.
     */
    public ActionServlet getServlet() {
        return this.servlet;
    }


    /**
     * Sets the servlet with which this handler is associated.
     *
     * @param servlet The associated servlet.
     */
    public void setServlet(ActionServlet servlet) {
        this.servlet = servlet;
    }


    /**
     * Retrieves the action mapping with which this handler is associated.
     *
     * @return The associated action mapping.
     */
    public ActionMapping getMapping() {
        return this.mapping;
    }


    /**
     * Sets the action mapping with which this handler is associated.
     *
     * @param mapping The associated action mapping.
     */
    public void setMapping(ActionMapping mapping) {
        this.mapping = mapping;
    }


    /**
     * Parses the input stream and partitions the parsed items into a set of
     * form fields and a set of file items. In the process, the parsed items
     * are translated from Commons FileUpload <code>FileItem</code> instances
     * to Struts <code>FormFile</code> instances.
     *
     * @param request The multipart request to be processed.
     *
     * @throws ServletException if an unrecoverable error occurs.
     */
    public void handleRequest(HttpServletRequest request)
            throws ServletException {

        // Get the app config for the current request.
        ModuleConfig ac = (ModuleConfig) request.getAttribute(
                Globals.MODULE_KEY);

        // Create and configure a DIskFileUpload instance.
        DiskFileUpload upload = new DiskFileUpload();
        // The following line is to support an "EncodingFilter"
        // see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23255
        upload.setHeaderEncoding(request.getCharacterEncoding());
        // Set the maximum size before a FileUploadException will be thrown.
        upload.setSizeMax(getSizeMax(ac));
        // Set the maximum size that will be stored in memory.
        upload.setSizeThreshold((int) getSizeThreshold(ac));
        // Set the the location for saving data on disk.
        upload.setRepositoryPath(getRepositoryPath(ac));

        // Create the hash tables to be populated.
        elementsText = new Hashtable();
        elementsFile = new Hashtable();
        elementsAll = new Hashtable();

        // Parse the request into file items.
        List items = null;
        try {
            items = upload.parseRequest(request);
        } catch (DiskFileUpload.SizeLimitExceededException e) {
            // Special handling for uploads that are too big.
            request.setAttribute(
                    MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED,
                    Boolean.TRUE);
            return;
        } catch (FileUploadException e) {
            log.error("Failed to parse multipart request", e);
            throw new ServletException(e);
        }

        // Partition the items into form fields and files.
        Iterator iter = items.iterator();
        while (iter.hasNext()) {
            FileItem item = (FileItem) iter.next();

            if (item.isFormField()) {
                addTextParameter(request, item);
            } else {
                addFileParameter(item);
            }
        }
    }


    /**
     * Returns a hash table containing the text (that is, non-file) request
     * parameters.
     *
     * @return The text request parameters.
     */
    public Hashtable getTextElements() {
        return this.elementsText;
    }


    /**
     * Returns a hash table containing the file (that is, non-text) request
     * parameters.
     *
     * @return The file request parameters.
     */
    public Hashtable getFileElements() {
        return this.elementsFile;
    }


    /**
     * Returns a hash table containing both text and file request parameters.
     *
     * @return The text and file request parameters.
     */
    public Hashtable getAllElements() {
        return this.elementsAll;
    }


    /**
     * Cleans up when a problem occurs during request processing.
     */
    public void rollback() {
        Iterator iter = elementsFile.values().iterator();

        while (iter.hasNext()) {
            FormFile formFile = (FormFile) iter.next();

            formFile.destroy();
        }
    }


    /**
     * Cleans up at the end of a request.
     */
    public void finish() {
        rollback();
    }


    // -------------------------------------------------------- Support Methods


    /**
     * Returns the maximum allowable size, in bytes, of an uploaded file. The
     * value is obtained from the current module's controller configuration.
     *
     * @param mc The current module's configuration.
     *
     * @return The maximum allowable file size, in bytes.
     */
    protected long getSizeMax(ModuleConfig mc) {
        return convertSizeToBytes(
                mc.getControllerConfig().getMaxFileSize(),
                DEFAULT_SIZE_MAX);
    }


    /**
     * Returns the size threshold which determines whether an uploaded file
     * will be written to disk or cached in memory.
     *
     * @param mc The current module's configuration.
     *
     * @return The size threshold, in bytes.
     */
    protected long getSizeThreshold(ModuleConfig mc) {
        return convertSizeToBytes(
                mc.getControllerConfig().getMemFileSize(),
                DEFAULT_SIZE_THRESHOLD);
    }

    /**
     * Converts a size value from a string representation to its numeric value.
     * The string must be of the form nnnm, where nnn is an arbitrary decimal
     * value, and m is a multiplier. The multiplier must be one of 'K', 'M' and
     * 'G', representing kilobytes, megabytes and gigabytes respectively.
     *
     * If the size value cannot be converted, for example due to invalid syntax,
     * the supplied default is returned instead.
     *
     * @param sizeString  The string representation of the size to be converted.
     * @param defaultSize The value to be returned if the string is invalid.
     *
     * @return The actual size in bytes.
     */
    protected long convertSizeToBytes(String sizeString, long defaultSize) {
        int multiplier = 1;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品你懂的在线| 久久精品国产亚洲aⅴ| 精久久久久久久久久久| 欧美日韩mp4| 亚洲国产欧美在线| 色综合久久精品| 日韩午夜小视频| 五月天婷婷综合| 欧美日韩一级黄| 亚洲一区二区欧美激情| 色网站国产精品| 亚洲免费在线电影| 色呦呦日韩精品| 伊人一区二区三区| 欧美日韩日日夜夜| 日日摸夜夜添夜夜添国产精品| 欧美午夜精品电影| 午夜精品福利一区二区蜜股av| 欧美在线看片a免费观看| 亚洲综合999| 欧美视频一区二区| 日韩专区在线视频| 日韩三级av在线播放| 美国毛片一区二区三区| 91精品国产91热久久久做人人| 免费成人在线视频观看| 精品欧美一区二区久久| 国产在线精品一区二区三区不卡| 久久综合精品国产一区二区三区| 国产麻豆成人精品| 国产精品成人一区二区艾草 | 精品午夜久久福利影院| 久久久久久99久久久精品网站| 国产高清精品久久久久| 亚洲人成小说网站色在线| 91久久精品一区二区| 亚洲成人三级小说| 日韩美一区二区三区| 国产精品18久久久久久久久久久久| 久久久蜜臀国产一区二区| 成人污视频在线观看| 综合分类小说区另类春色亚洲小说欧美 | 精品久久久网站| 国产成人av网站| 综合激情成人伊人| 欧美一区二区三区视频免费| 日韩电影在线观看网站| 国产亚洲欧美日韩在线一区| 99久久久精品| 美女一区二区视频| 亚洲欧洲色图综合| 91精品国产色综合久久ai换脸| 国内成+人亚洲+欧美+综合在线| 久久久午夜精品理论片中文字幕| 国产99精品国产| 亚洲香肠在线观看| 久久伊人中文字幕| 91福利社在线观看| 亚洲精品videosex极品| 麻豆精品视频在线观看| 日韩一区二区三区视频在线观看| 久久久久久久综合狠狠综合| 蜜桃av一区二区三区电影| 欧美性色欧美a在线播放| 99视频在线精品| 久久66热re国产| 在线免费不卡电影| 欧美日韩精品二区第二页| 国产精品一区二区三区网站| 天天综合色天天综合| 一区二区三区电影在线播| 国产免费成人在线视频| 欧美va亚洲va| 欧美一级在线免费| 欧美人牲a欧美精品| 在线看国产一区二区| 色综合天天综合在线视频| 成人久久18免费网站麻豆| 国产很黄免费观看久久| 国产一区二区三区美女| 国产毛片精品视频| 国产一区 二区 三区一级| 国产一区二区女| 国产精品系列在线播放| 国产真实乱子伦精品视频| 精品一区二区三区在线播放| 奇米亚洲午夜久久精品| 日本不卡123| 久久精品99国产国产精| 久久国产综合精品| 精品一区二区三区视频在线观看| 免费在线欧美视频| 久久99国产精品久久| 国产综合色精品一区二区三区| 久久av中文字幕片| 国产一区欧美一区| 成人福利视频网站| 99精品久久免费看蜜臀剧情介绍| 色综合夜色一区| 欧美色偷偷大香| 日韩一区二区精品在线观看| 欧美成人r级一区二区三区| 欧美大片一区二区| 国产亚洲欧洲一区高清在线观看| 中文字幕av一区二区三区| 国产精品久久久久久久久晋中| 亚洲啪啪综合av一区二区三区| 亚洲伦在线观看| 亚洲国产精品久久人人爱| 青青国产91久久久久久| 国产一区二区视频在线| 91小视频免费看| 欧美一区二区日韩| 国产亚洲精品中文字幕| 亚洲欧美日韩电影| 亚洲一二三四区不卡| 激情欧美日韩一区二区| aaa欧美大片| 欧美一区二区人人喊爽| 亚洲国产精品精华液2区45| 一区二区三区视频在线观看| 免费观看30秒视频久久| 成人h动漫精品一区二区| 欧美日韩亚洲国产综合| 久久久久久毛片| 亚洲成人动漫在线免费观看| 国产精品12区| 欧美高清dvd| 国产精品第五页| 老司机精品视频线观看86| 99久久国产综合精品色伊| 91精选在线观看| 1024成人网| 国产一区二区三区综合| 欧美日韩视频在线第一区 | 色菇凉天天综合网| 欧美一级专区免费大片| 亚洲欧美日韩中文播放 | 日韩va欧美va亚洲va久久| 国产福利一区二区| 777亚洲妇女| 亚洲伦理在线免费看| 成人亚洲一区二区一| 日韩一级精品视频在线观看| 一区二区在线看| 成人午夜av影视| 久久久影视传媒| 美国三级日本三级久久99| 欧美日韩综合在线免费观看| 中文字幕制服丝袜一区二区三区| 久久精品国产99国产| 欧美无砖专区一中文字| 亚洲日本韩国一区| 成人性生交大片免费| 欧美一区二区三区的| 亚洲电影第三页| 91女神在线视频| 国产精品福利影院| 国产一区二区在线观看视频| 欧美肥妇毛茸茸| 亚洲午夜羞羞片| 在线视频中文字幕一区二区| 国产精品成人午夜| 国产精品69毛片高清亚洲| 精品国产一区二区三区四区四| 婷婷久久综合九色综合伊人色| 色素色在线综合| 一区二区三区中文字幕电影 | 日韩一区二区影院| 视频在线观看国产精品| 欧美人与性动xxxx| 日韩精品每日更新| 欧美精品18+| 日本欧美大码aⅴ在线播放| 69堂成人精品免费视频| 日本欧美一区二区三区乱码| 91精品国产综合久久福利软件| 日韩va欧美va亚洲va久久| 日韩三级视频在线看| 国产在线麻豆精品观看| 欧美—级在线免费片| 成人一二三区视频| 国产精品国产三级国产普通话99| 91小视频在线免费看| 亚洲国产毛片aaaaa无费看| 欧美日韩不卡一区| 另类小说综合欧美亚洲| 久久久久久久综合色一本| 处破女av一区二区| 中文字幕中文字幕一区二区| 日本高清免费不卡视频| 日韩激情一区二区| 久久这里只有精品6| 波多野结衣亚洲| 亚洲一级在线观看| 欧美电影免费观看高清完整版| 国产电影一区二区三区| 亚洲欧美激情小说另类| 欧美精品在欧美一区二区少妇| 久久国产成人午夜av影院|