All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gitee.apanlh.spring.web.resolver.FormDataResolver Maven / Gradle / Ivy

There is a newer version: 2.0.0.2
Show newest version
package com.gitee.apanlh.spring.web.resolver;

import com.gitee.apanlh.web.model.RequestDataType;
import com.gitee.apanlh.web.model.WebFile;
import com.gitee.apanlh.web.model.vo.RequestVO;
import com.gitee.apanlh.web.util.ServletUtils;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;

/**	
 * 	FormData对象解析
 * 
 * 	@author Pan
 */
class FormDataResolver implements RequestParamResolverStrategy {
	
	/**
	 * 	默认构造函数
	 * 
	 * 	@author Pan
	 */
	FormDataResolver() {
		super();
	}
	
	@Override
	public RequestVO resolve() {
		return null;
	}
	
	@Override
	public RequestVO resolve(HttpServletRequest request, RequestVO params, RequestDataType dataType) {
		MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
		params.setParams(ServletUtils.getParams(request));
		WebFile webFile = new WebFile(multipartRequest.getMultiFileMap());
		
		if (webFile.getSize() > 0) {
			params.setWebFile(webFile);
			dataType.setHasFile(true);
		}
		
		dataType.setHasFormData(true);
		return params;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy