⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uploadaction.java

📁 OPIAM stands for Open Identity and Access Management. This Suite will provide modules for user & rig
💻 JAVA
字号:
/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.struts.actions;

//DW/2622/BeginPatch
import opiam.admin.faare.MessageUtil;
//DW/2622/EndPatch
//DW/2625/BeginPatch
import opiam.admin.faare.struts.managers.AppliParametersManager;
//DW/2625/EndPatch
import opiam.admin.faare.struts.forms.UploadForm;

import org.apache.commons.beanutils.PropertyUtils;

import org.apache.log4j.Logger;

import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.IOException;

import java.util.Collection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * This class allows to upload a file to the server and to add it to an object.
 * It uses the UploadForm form bean.
 * <br>
 * HTTP PARAMETERS :<br>
 * <li>objname : name of the object which will be augmented.</li>
 * <li>attname : name of the property of the objecty which will store the file contents.
 *    It must be a java.util.Collection.</li>
 *
 */
public class UploadAction extends SecureAction
{
    /** Logger de log4j. */
    private static Logger _logger = Logger.getLogger(UploadAction.class);

    /** read buffer size. */
    private static final int BUFSIZE = 8192;

    /** maximum size. */
    private static final int DEF_MAXSIZE = 4096000;

    /**
     * Struts Action method.
     * See ScureAction
     *
     * @param mapping Struts mapping data.
     * @param form Input form.
     * @param request HTTP request.
     * @param response HTTP response.
     *
     * @return forward to display or null
     *
     * @throws java.io.IOException see Action.execute()
     * @throws javax.servlet.ServletException see Action.execute()
     */
    public ActionForward secureExecute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        if (form instanceof UploadForm)
        {
            //this line is here for when the input page is upload-utf8.jsp,
            //it sets the correct character encoding for the response
            String encoding = request.getCharacterEncoding();

            if ((encoding != null) && (encoding.equalsIgnoreCase("utf-8")))
            {
                response.setContentType("text/html; charset=utf-8");
            }

            // parameters : nom d'objet 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -