当前位置: 首页>>代码示例>>Java>>正文


Java MultipartRequestHandler类代码示例

本文整理汇总了Java中org.apache.struts.upload.MultipartRequestHandler的典型用法代码示例。如果您正苦于以下问题:Java MultipartRequestHandler类的具体用法?Java MultipartRequestHandler怎么用?Java MultipartRequestHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MultipartRequestHandler类属于org.apache.struts.upload包,在下文中一共展示了MultipartRequestHandler类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
/**
 *  Check to make sure the client hasn't exceeded the maximum allowed upload size inside of this validate
 *  method.
 *
 * @param  mapping  ActionMapping
 * @param  request  HttpServletRequest
 * @return          ActionErrors
 */
public ActionErrors validate(
                             ActionMapping mapping,
                             HttpServletRequest request) {

	ActionErrors errors = null;
	//has the maximum length been exceeded?
	Boolean maxLengthExceeded =
		(Boolean) request.getAttribute(
		MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
	
			
	if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) {
		errors = new ActionErrors();
		errors.add(
			ActionMessages.GLOBAL_MESSAGE,
			new ActionMessage("maxLengthExceeded"));
	}
	
	return errors;
}
 
开发者ID:NCAR,项目名称:dls-repository-stack,代码行数:29,代码来源:UploadForm.java

示例2: getAllParameters

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
/**
 * すべてのパラメータを返します。
 * 
 * @param request
 *            リクエスト
 * @param multipartHandler
 *            マルチパートリクエストハンドラ
 * @return すべてのパラメータ
 */
@SuppressWarnings("unchecked")
protected Map<String, Object> getAllParameters(HttpServletRequest request,
        MultipartRequestHandler multipartHandler) {
    Map<String, Object> params = new HashMap<String, Object>();
    if (request instanceof MultipartRequestWrapper) {
        request = ((MultipartRequestWrapper) request).getRequest();
    }
    Enumeration e = request.getParameterNames();
    while (e.hasMoreElements()) {
        String name = (String) e.nextElement();
        params.put(name, request.getParameterValues(name));
    }
    if (multipartHandler != null) {
        Hashtable elements = multipartHandler.getAllElements();
        params.putAll(elements);
    }
    return params;
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:28,代码来源:S2RequestProcessor.java

示例3: testGetAllParameters

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
/**
 * @throws Exception
 */
public void testGetAllParameters() throws Exception {
    MultipartRequestHandler multipartHandler = new CommonsMultipartRequestHandler() {

        @SuppressWarnings("unchecked")
        @Override
        public Hashtable getAllElements() {
            Hashtable elements = new Hashtable();
            elements.put("aaa", "111");
            return elements;
        }

    };
    getRequest().addParameter("bbb", "222");
    HttpServletRequest request = new MultipartRequestWrapper(getRequest());
    S2RequestProcessor processor = new S2RequestProcessor();
    Map<String, Object> params = processor.getAllParameters(request,
            multipartHandler);
    assertEquals("111", params.get("aaa"));
    assertEquals("222", ((String[]) params.get("bbb"))[0]);
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:24,代码来源:S2RequestProcessorTest.java

示例4: setServletFor

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
/**
 * <p>Set servlet to a <code>MultipartRequestHandler</code>.</p>
 *
 * @param object The MultipartRequestHandler
 */
 public void setServletFor(MultipartRequestHandler object) {

    object.setServlet(this.servlet);
    // :FIXME: Should this be based on an "setServlet"
    // interface or introspection for a setServlet method?
    // Or, is it safer to just add the types we want as we want them?

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:ActionServletWrapper.java

示例5: setServletFor

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
/**
 * <p>Set servlet to a <code>MultipartRequestHandler</code>.</p>
 *
 * @param object The MultipartRequestHandler
 */
public void setServletFor(MultipartRequestHandler object) {
    object.setServlet(this.servlet);

    // :FIXME: Should this be based on an "setServlet"
    // interface or introspection for a setServlet method?
    // Or, is it safer to just add the types we want as we want them?
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:13,代码来源:ActionServletWrapper.java

示例6: sendReply

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
public ActionForward sendReply(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	LoggedInInfo loggedInInfo = LoggedInInfo.getLoggedInInfoFromSession(request);
	Long replyToMessageId = new Long(request.getParameter("replyToMessageId"));
	String message = StringUtils.trimToNull(request.getParameter("body"));
	boolean replyAll = Boolean.parseBoolean(request.getParameter("replyAll"));
	boolean saveFileAttachmentToDocs = WebUtils.isChecked(request, "saveFileAttachmentToDocs");

	MultipartRequestHandler multipartRequestHandler = form.getMultipartRequestHandler();
	@SuppressWarnings("unchecked")
	Hashtable<String, FormFile> fileElements = multipartRequestHandler.getFileElements();
	FormFile attachment = fileElements.get("fileAttachment");

	MyOscarLoggedInInfo myOscarLoggedInInfo = MyOscarLoggedInInfo.getLoggedInInfo(request.getSession());
	MessageTransfer3 previousMessage = MessageManager.getMessage(myOscarLoggedInInfo, replyToMessageId);

	Message2DataTransfer subjectPart = MessageManager.getMessage2DataTransfer(previousMessage, "SUBJECT");
	String replySubject = "re: " + (subjectPart != null ? new String(subjectPart.getContents(), "UTF-8") : "");

	MessageTransfer3 newMessage = MessageManager.makeBasicMessageTransfer(myOscarLoggedInInfo, replyToMessageId, null, replySubject, message);
	List<Long> recipientList = newMessage.getRecipientPeopleIds();
	
	if (previousMessage.getReplyToPersonId()!=null) recipientList.add(previousMessage.getReplyToPersonId());
	else recipientList.add(previousMessage.getSenderPersonId());

	if (replyAll) {
		for (Long recipientId : previousMessage.getRecipientPeopleIds()) {
			if (myOscarLoggedInInfo.getLoggedInPersonId().equals(recipientId)) continue;

			recipientList.add(recipientId);
		}
	}

	Message2DataTransfer attachmentPart = null;
	if (attachment != null) {
		attachmentPart = makeFileAttachmentMessagePart(attachment);
		if (attachmentPart != null) newMessage.getMessageDataList().add(attachmentPart);
	}

	Long messageId = null;
	try {
		messageId = MessageManager.sendMessage(myOscarLoggedInInfo, newMessage);
		
		if (attachmentPart != null && saveFileAttachmentToDocs) {
			Long senderPersonId = previousMessage.getSenderPersonId();
			MinimalPersonTransfer2 minimalPersonSender = AccountManager.getMinimalPerson(myOscarLoggedInInfo, senderPersonId);
			String myOscarUserName = minimalPersonSender.getUserName();
			Demographic demographic = MyOscarUtils.getDemographicByMyOscarUserName(myOscarUserName);

			saveToDocs(loggedInInfo, demographic.getDemographicNo(), attachment, replySubject);
		}
	} catch (NotAuthorisedException_Exception e) {
		WebUtils.addErrorMessage(request.getSession(), "This patient has not given you permissions to send them a message.");
		return mapping.findForward("create");
	}

	if (messageId != null && request.getParameter("andPasteToEchart") != null && request.getParameter("andPasteToEchart").equals("yes")) {
		ActionRedirect redirect = new ActionRedirect(mapping.findForward("echart"));
		redirect.addParameter("myoscarmsg", messageId.toString());
		redirect.addParameter("remyoscarmsg", replyToMessageId.toString());
		redirect.addParameter("appointmentDate", UtilDateUtilities.DateToString(new Date())); //Makes echart note have todays date, which makes sense because we are reply now
		redirect.addParameter("demographicNo", request.getParameter("demographicNo"));
		return redirect;
	}

	return mapping.findForward("view");
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:67,代码来源:PHRMessageAction.java

示例7: sendPatient

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
public ActionForward sendPatient(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
	LoggedInInfo loggedInInfo = LoggedInInfo.getLoggedInInfoFromSession(request);
	String subject = request.getParameter("subject");
	String messageBody = request.getParameter("body");
	Integer demographicId = Integer.parseInt(request.getParameter("demographicId"));
	boolean saveFileAttachmentToDocs = WebUtils.isChecked(request, "saveFileAttachmentToDocs");

	MultipartRequestHandler multipartRequestHandler = form.getMultipartRequestHandler();
	@SuppressWarnings("unchecked")
	Hashtable<String, FormFile> fileElements = multipartRequestHandler.getFileElements();
	FormFile attachment = fileElements.get("fileAttachment");

	MyOscarLoggedInInfo myOscarLoggedInInfo = MyOscarLoggedInInfo.getLoggedInInfo(request.getSession());

	DemographicDao demographicDao = (DemographicDao) SpringUtils.getBean("demographicDao");
	Demographic demographic = demographicDao.getDemographicById(demographicId);
	Long recipientMyOscarUserId = AccountManager.getUserId(myOscarLoggedInInfo, demographic.getMyOscarUserName());

	MessageTransfer3 newMessage = MessageManager.makeBasicMessageTransfer(myOscarLoggedInInfo, null, null, subject, messageBody);
	List<Long> recipientList = newMessage.getRecipientPeopleIds();
	recipientList.add(recipientMyOscarUserId);

	Message2DataTransfer attachmentPart = null;
	if (attachment != null) {
		attachmentPart = makeFileAttachmentMessagePart(attachment);
		if (attachmentPart != null) newMessage.getMessageDataList().add(attachmentPart);
	}

	try {
		MessageManager.sendMessage(myOscarLoggedInInfo, newMessage);

		if (attachmentPart != null && saveFileAttachmentToDocs) {
			saveToDocs(loggedInInfo, demographicId, attachment, subject);
		}
	} catch (NotAuthorisedException_Exception e) {
		WebUtils.addErrorMessage(request.getSession(), "This patient has not given you permissions to send them a message.");
		return mapping.findForward("create");
	}

	return mapping.findForward("view");
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:42,代码来源:PHRMessageAction.java

示例8: processPopulate

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
@Override
protected void processPopulate(HttpServletRequest request,
        HttpServletResponse response, ActionForm form, ActionMapping mapping)
        throws ServletException {

    if (form == null) {
        return;
    }
    form.setServlet(servlet);
    String contentType = request.getContentType();
    String method = request.getMethod();
    form.setMultipartRequestHandler(null);
    MultipartRequestHandler multipartHandler = null;
    if (contentType != null
            && contentType.startsWith("multipart/form-data")
            && method.equalsIgnoreCase("POST")) {
        multipartHandler = getMultipartHandler(mapping.getMultipartClass());
        if (multipartHandler != null) {
            multipartHandler.setServlet(servlet);
            multipartHandler.setMapping(mapping);
            multipartHandler.handleRequest(request);
            Boolean maxLengthExceeded = (Boolean) request
                    .getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
            if ((maxLengthExceeded != null)
                    && (maxLengthExceeded.booleanValue())) {
                form.setMultipartRequestHandler(multipartHandler);
                processExecuteConfig(request, response, mapping);
                return;
            }
            SingletonS2ContainerFactory.getContainer().getExternalContext()
                    .setRequest(request);
        }
    }
    processExecuteConfig(request, response, mapping);
    form.reset(mapping, request);
    Map<String, Object> params = getAllParameters(request, multipartHandler);
    S2ActionMapping actionMapping = (S2ActionMapping) mapping;
    for (Iterator<String> i = params.keySet().iterator(); i.hasNext();) {
        String name = i.next();
        try {
            setProperty(actionMapping.getActionForm(), name, params
                    .get(name));
        } catch (Throwable t) {
            throw new IllegalPropertyRuntimeException(actionMapping
                    .getActionFormBeanDesc().getBeanClass(), name, t);
        }
    }
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:49,代码来源:S2RequestProcessor.java

示例9: getMultipartRequestHandler

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
/**
 * <p>Return the <code>MultipartRequestHandler</code> for this form
 * The reasoning behind this is to give form bean developers
 * control over the lifecycle of their multipart requests
 * through the use of the <code>finish</code> and/or <code>rollback</code>
 * methods of <code>MultipartRequestHandler</code>.  This method will return
 * <code>null</code> if this form's enctype is not
 * "multipart/request-data".</p>
 *
 * @see org.apache.struts.upload.MultipartRequestHandler
 */
public MultipartRequestHandler getMultipartRequestHandler() {
    return multipartRequestHandler;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:ActionForm.java

示例10: setMultipartRequestHandler

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
/**
 * <p>Set the Handler provides to use in dealing with file uploads.</p>
 *
 * @param multipartRequestHandler The Handler to use for fileuploads.
 */
public void setMultipartRequestHandler(MultipartRequestHandler multipartRequestHandler) {

    this.multipartRequestHandler = multipartRequestHandler;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:ActionForm.java

示例11: getMultipartRequestHandler

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
/**
 * <p>Return the <code>MultipartRequestHandler</code> for this form The
 * reasoning behind this is to give form bean developers control over the
 * lifecycle of their multipart requests through the use of the
 * <code>finish</code> and/or <code>rollback</code> methods of
 * <code>MultipartRequestHandler</code>.  This method will return
 * <code>null</code> if this form's enctype is not "multipart/form-data".
 * </p>
 *
 * @return The {@link org.apache.struts.upload.MultipartRequestHandler}
 *         for this form.
 * @see org.apache.struts.upload.MultipartRequestHandler
 */
public MultipartRequestHandler getMultipartRequestHandler() {
    return multipartRequestHandler;
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:17,代码来源:ActionForm.java

示例12: setMultipartRequestHandler

import org.apache.struts.upload.MultipartRequestHandler; //导入依赖的package包/类
/**
 * <p>Set the Handler provided for use in dealing with file uploads.</p>
 *
 * @param multipartRequestHandler The Handler to use for fileuploads.
 */
public void setMultipartRequestHandler(
    MultipartRequestHandler multipartRequestHandler) {
    this.multipartRequestHandler = multipartRequestHandler;
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:10,代码来源:ActionForm.java


注:本文中的org.apache.struts.upload.MultipartRequestHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。