本文整理汇总了Java中org.apache.struts.upload.MultipartRequestWrapper类的典型用法代码示例。如果您正苦于以下问题:Java MultipartRequestWrapper类的具体用法?Java MultipartRequestWrapper怎么用?Java MultipartRequestWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MultipartRequestWrapper类属于org.apache.struts.upload包,在下文中一共展示了MultipartRequestWrapper类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processMultipart
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
/**
* <p>If this is a multipart request, wrap it with a special wrapper.
* Otherwise, return the request unchanged.</p>
*
* @param request The HttpServletRequest we are processing
*/
protected HttpServletRequest processMultipart(HttpServletRequest request) {
if (!"POST".equalsIgnoreCase(request.getMethod())) {
return (request);
}
String contentType = request.getContentType();
if ((contentType != null) &&
contentType.startsWith("multipart/form-data")) {
return (new MultipartRequestWrapper(request));
} else {
return (request);
}
}
示例2: doInclude
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
/**
* <p>Do an include of specified URI using a <code>RequestDispatcher</code>.
* This method is used by all internal method needing to do an include.</p>
*
* @param uri Context-relative URI to include
* @param request Current page request
* @param response Current page response
* @since Struts 1.1
*/
protected void doInclude(
String uri,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Unwrap the multipart request, if there is one.
if (request instanceof MultipartRequestWrapper) {
request = ((MultipartRequestWrapper) request).getRequest();
}
RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
if (rd == null) {
response.sendError(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
getInternal().getMessage("requestDispatcher", uri));
return;
}
rd.include(request, response);
}
示例3: getAllParameters
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的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;
}
示例4: testGetAllParameters
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的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]);
}
示例5: execute
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
/**
* Process the specified HTTP request, and create the corresponding HTTP
* response (or forward to another web component that will create it).
* Return an <code>ActionForward</code> instance describing where and how
* control should be forwarded, or <code>null</code> if the response has
* already been completed.
*
* @param mapping The ActionMapping used to select this instance
* @param form The optional ActionForm bean for this request (if any)
* @param request The HTTP request we are processing
* @param response The HTTP response we are creating
*
* @exception Exception if an error occurs
*/
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
// Create a RequestDispatcher the corresponding resource
String path = mapping.getParameter();
if (path == null) {
throw new ServletException(messages.getMessage("include.path"));
}
RequestDispatcher rd =
servlet.getServletContext().getRequestDispatcher(path);
if (rd == null) {
throw new ServletException(messages.getMessage("include.rd", path));
}
// Unwrap the multipart request, if there is one.
if (request instanceof MultipartRequestWrapper) {
request = ((MultipartRequestWrapper) request).getRequest();
}
// Forward control to the specified resource
rd.include(request, response);
// Tell the controller servlet that the response has been created
return (null);
}
示例6: getMultipartRequestWrapper
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
/**
* The multipart object for this request.
*/
public MultipartRequestWrapper getMultipartRequestWrapper() {
if (this.request == null) {
return null;
}
return (MultipartRequestWrapper) this.request.getAttribute(Globals.MULTIPART_KEY);
}
示例7: doForward
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
/**
* <p>Do a forward to specified URI using a <code>RequestDispatcher</code>.
* This method is used by all internal method needing to do a forward.</p>
*
* @param uri Context-relative URI to forward to
* @param request Current page request
* @param response Current page response
* @since Struts 1.1
*/
protected void doForward(
String uri,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Unwrap the multipart request, if there is one.
if (request instanceof MultipartRequestWrapper) {
request = ((MultipartRequestWrapper) request).getRequest();
}
RequestDispatcher rd = getServletContext().getRequestDispatcher(uri);
if (rd == null) {
response.sendError(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
getInternal().getMessage("requestDispatcher", uri));
return;
}
rd.forward(request, response);
}
示例8: processMultipart
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
/**
* <p>If this is a multipart request, wrap it with a special wrapper.
* Otherwise, return the request unchanged.</p>
*
* @param request The HttpServletRequest we are processing
* @return Original or wrapped request as appropriate
*/
protected HttpServletRequest processMultipart(HttpServletRequest request) {
if (!"POST".equalsIgnoreCase(request.getMethod())) {
return (request);
}
String contentType = request.getContentType();
if ((contentType != null)
&& contentType.startsWith("multipart/form-data")) {
return (new MultipartRequestWrapper(request));
} else {
return (request);
}
}
示例9: getMultipartRequestWrapper
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
/**
* <p> The multipart object for this request. </p>
*/
public MultipartRequestWrapper getMultipartRequestWrapper() {
if (this.request == null) {
return null;
}
return (MultipartRequestWrapper) this.request.getAttribute(Globals.MULTIPART_KEY);
}
示例10: processMultipart
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
/**
* <p>If this is a multipart request, wrap it with a special wrapper.
* Otherwise, return the request unchanged.</p>
*
* @param request The HttpServletRequest we are processing
* @return A wrapped request, if the request is multipart; otherwise the
* original request.
*/
protected HttpServletRequest processMultipart(HttpServletRequest request) {
if (!"POST".equalsIgnoreCase(request.getMethod())) {
return (request);
}
String contentType = request.getContentType();
if ((contentType != null)
&& contentType.startsWith("multipart/form-data")) {
return (new MultipartRequestWrapper(request));
} else {
return (request);
}
}
示例11: addTextParameter
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void addTextParameter(HttpServletRequest request, FileItem item) {
String name = item.getFieldName();
String value = null;
boolean haveValue = false;
String encoding = request.getCharacterEncoding();
if (encoding != null) {
try {
value = item.getString(encoding);
haveValue = true;
} catch (Exception e) {
}
}
if (!haveValue) {
try {
value = item.getString("ISO-8859-1");
} catch (java.io.UnsupportedEncodingException uee) {
value = item.getString();
}
haveValue = true;
}
if (request instanceof MultipartRequestWrapper) {
MultipartRequestWrapper wrapper = (MultipartRequestWrapper) request;
wrapper.setParameter(name, value);
}
String[] oldArray = (String[]) elementsText.get(name);
String[] newArray;
if (oldArray != null) {
newArray = new String[oldArray.length + 1];
System.arraycopy(oldArray, 0, newArray, 0, oldArray.length);
newArray[oldArray.length] = value;
} else {
newArray = new String[] { value };
}
elementsText.put(name, newArray);
elementsAll.put(name, newArray);
}
示例12: getMultipartRequestWrapper
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
/**
* The multipart object for this request.
*/
public MultipartRequestWrapper getMultipartRequestWrapper();
示例13: getMultipartRequestWrapper
import org.apache.struts.upload.MultipartRequestWrapper; //导入依赖的package包/类
/**
* <p> The multipart object for this request. </p>
*/
public MultipartRequestWrapper getMultipartRequestWrapper();