亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
亚洲日本在线看| 精品国免费一区二区三区| 国产精品一区在线观看你懂的| 国产精品第一页第二页第三页| 国产亚洲欧美激情| 国产精品欧美一区二区三区| 国产女人水真多18毛片18精品视频 | 激情综合色综合久久综合| 日本不卡一二三区黄网| 蜜芽一区二区三区| 成人午夜电影久久影院| 成人美女在线视频| 亚洲欧美日韩国产成人精品影院| 国产亚洲一本大道中文在线| 欧美国产日韩在线观看| 亚洲免费观看视频| 日本免费新一区视频| 午夜精品久久一牛影视| 久久99精品视频| 国产成人午夜视频| 91精品国产美女浴室洗澡无遮挡| 精品久久久久久久久久久院品网| 欧美韩日一区二区三区| 午夜精品福利久久久| 粉嫩绯色av一区二区在线观看| 色偷偷88欧美精品久久久| 精品国产免费视频| 无码av中文一区二区三区桃花岛| 美国毛片一区二区| 欧美视频在线播放| 中文字幕巨乱亚洲| 国产999精品久久久久久| 91麻豆精品国产91久久久| 亚洲欧美偷拍三级| 久久99国产精品久久99| 欧美日韩精品一区二区三区 | 一区二区三区自拍| 国产乱人伦精品一区二区在线观看| 在线中文字幕不卡| 综合久久给合久久狠狠狠97色 | 国产91露脸合集magnet| 日韩视频免费观看高清在线视频| 亚洲丝袜另类动漫二区| av在线播放成人| 亚洲色图色小说| 99国产麻豆精品| 一区二区三区在线视频观看58| 国产91精品久久久久久久网曝门| 精品成人在线观看| 国产乱码精品一区二区三区五月婷| 欧美高清视频在线高清观看mv色露露十八| 99精品桃花视频在线观看| 亚洲天天做日日做天天谢日日欢| 国产成人99久久亚洲综合精品| 欧美激情综合在线| 91看片淫黄大片一级在线观看| 亚洲激情自拍视频| 精品福利在线导航| 99久久精品免费精品国产| 亚洲精品乱码久久久久久黑人 | 国产亚洲一区二区三区| av在线免费不卡| 日韩av中文字幕一区二区三区| 这里只有精品免费| 国产91在线|亚洲| 亚洲图片一区二区| 国产日韩欧美在线一区| 精品污污网站免费看| 国产福利不卡视频| 天堂蜜桃91精品| 亚洲日本丝袜连裤袜办公室| 91久久线看在观草草青青| 国产在线播放一区| 亚洲成人免费av| 国产婷婷色一区二区三区四区 | 国产精品不卡在线| 久久看人人爽人人| 欧美精选在线播放| 色欲综合视频天天天| 国产伦理精品不卡| 国内外成人在线| 三级影片在线观看欧美日韩一区二区| 国产精品九色蝌蚪自拍| 精品国产免费人成电影在线观看四季 | 国产精品亚洲一区二区三区在线| 亚洲卡通欧美制服中文| 亚洲精品日产精品乱码不卡| 国产女主播一区| 国产精品理论在线观看| 精品福利av导航| 精品日韩欧美一区二区| 久久精品人人爽人人爽| 国产精品免费久久| 亚洲人吸女人奶水| 一区二区三区美女视频| 亚洲三级在线播放| 亚洲另类在线一区| 青娱乐精品视频| 国产成人免费视频网站高清观看视频| 美脚の诱脚舐め脚责91| 国产成人在线看| av爱爱亚洲一区| 欧美日韩中文另类| 337p日本欧洲亚洲大胆色噜噜| 久久久蜜桃精品| 亚洲成人av资源| 精品一区二区在线观看| 成人午夜激情在线| 欧美亚洲国产一区二区三区va| 在线播放91灌醉迷j高跟美女 | 亚洲视频免费在线观看| 日本中文字幕不卡| av一区二区久久| 日韩一区二区在线看| 亚洲三级小视频| 日韩精品一二三| 在线观看欧美黄色| 欧美激情一区二区三区蜜桃视频| 五月激情六月综合| 成人黄色软件下载| 亚洲国产精品激情在线观看| 亚洲成人福利片| 一本久道中文字幕精品亚洲嫩| 欧美成人精精品一区二区频| 亚洲伦理在线免费看| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 亚洲国产精品视频| 日本乱码高清不卡字幕| 最新高清无码专区| 九色|91porny| 久久伊99综合婷婷久久伊| 日韩二区三区四区| 欧美一级生活片| 日韩主播视频在线| 日韩免费成人网| 国产一区二区剧情av在线| 91精品国产一区二区三区香蕉| 亚洲国产精品久久艾草纯爱| 99精品视频免费在线观看| 国产精品久久久久久户外露出 | 日韩黄色免费电影| 日韩一区二区三区四区五区六区 | av一区二区久久| 亚洲色图制服丝袜| 91国模大尺度私拍在线视频| 中文字幕亚洲综合久久菠萝蜜| 色国产综合视频| 男女性色大片免费观看一区二区| 欧美一级一区二区| 国产成人av一区| 亚洲人成亚洲人成在线观看图片 | 日韩欧美国产一区二区在线播放| 美洲天堂一区二卡三卡四卡视频 | 一区二区三区在线看| 69av一区二区三区| 国产精品一区一区| 中文字幕中文字幕一区二区| 91精品国产欧美日韩| av一区二区三区在线| 日韩国产欧美一区二区三区| 国产亚洲精品久| 7777精品伊人久久久大香线蕉超级流畅 | 亚洲天堂精品在线观看| 欧美日韩国产a| 色综合一个色综合亚洲| 久久精品国产99国产| 亚洲制服丝袜一区| 日本一区二区动态图| 精品日韩欧美一区二区| 欧美私人免费视频| 99久久99久久精品免费看蜜桃| 免费视频最近日韩| 日本网站在线观看一区二区三区| 亚洲视频网在线直播| 国产免费久久精品| 国产亚洲精品aa| 精品日韩一区二区三区| 欧美一卡二卡在线| 日韩一区二区精品在线观看| 99久久精品免费| 99国内精品久久| 欧美中文一区二区三区| 欧美日韩综合色| 日韩欧美一区中文| 久久综合久久综合久久| 日韩美女视频在线| 中文字幕av资源一区| 亚洲精品亚洲人成人网| 亚洲一区二区三区四区在线 | 在线观看免费亚洲| 欧美日韩国产精品自在自线| 欧美精选一区二区| 精品伦理精品一区| 国产精品三级av在线播放| 国产精品国产精品国产专区不片| 专区另类欧美日韩| 日韩激情中文字幕| 精品制服美女丁香| 日本精品免费观看高清观看| 欧美三级午夜理伦三级中视频|