change the bug in upload param files
This commit is contained in:
parent
e3fca3fcfd
commit
18113d3f35
|
@ -17,7 +17,6 @@ import org.bench4q.web.model.BaseResponseModel;
|
|||
import org.bench4q.web.service.BaseService;
|
||||
import org.bench4q.web.service.CommunicateWithMaster;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.SessionAttributes;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
@ -265,7 +265,7 @@ public class ScriptActionController {
|
|||
|
||||
@RequestMapping("saveRecordScript")
|
||||
public @ResponseBody
|
||||
BaseResponseModel saveScriptToDB(HttpServletRequest request,
|
||||
BaseResponseModel saveScriptToDB(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam String port, @RequestParam String scriptName,
|
||||
@RequestParam String fileNameUUID) throws CustomGenericException {
|
||||
|
@ -293,9 +293,11 @@ public class ScriptActionController {
|
|||
@ResponseBody
|
||||
public BaseResponseModel uploadScript(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam("script") CommonsMultipartFile script,
|
||||
@RequestParam String scriptName, CommonsMultipartFile[] paramFiles)
|
||||
@RequestParam("script") MultipartFile script,
|
||||
@RequestParam String scriptName,
|
||||
@RequestParam(required = false) MultipartFile[] paramFiles)
|
||||
throws CustomGenericException {
|
||||
|
||||
if (script.isEmpty()) {
|
||||
return new BaseResponseModel(false, "empty file");
|
||||
}
|
||||
|
@ -320,7 +322,7 @@ public class ScriptActionController {
|
|||
else
|
||||
return new BaseResponseModel(false,
|
||||
operateScriptServerResponseModel.getFailCauseString());
|
||||
} catch (JAXBException e) {
|
||||
} catch (JAXBException | IOException e) {
|
||||
Logger.getLogger(ScriptActionController.class).info(
|
||||
ExceptionLog.getStackTrace(e));
|
||||
return new BaseResponseModel(false,
|
||||
|
@ -397,7 +399,7 @@ public class ScriptActionController {
|
|||
public BaseResponseModel uploadEditScript(
|
||||
@ModelAttribute("accessToken") String accessToken,
|
||||
@RequestParam String content,
|
||||
@RequestParam CommonsMultipartFile[] paramFiles)
|
||||
@RequestParam(required = false) MultipartFile[] paramFiles)
|
||||
throws CustomGenericException {
|
||||
ScenarioModel scenarioModel = null;
|
||||
Gson gson = new Gson();
|
||||
|
|
|
@ -12,7 +12,8 @@ import org.bench4q.share.communication.HttpRequester.HttpResponse;
|
|||
import org.bench4q.share.helper.MarshalHelper;
|
||||
import org.bench4q.share.models.master.OperateScriptServerResponseModel;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartRequest;
|
||||
|
||||
@Component
|
||||
public class ScriptMessager extends MasterMessager {
|
||||
|
@ -51,7 +52,7 @@ public class ScriptMessager extends MasterMessager {
|
|||
|
||||
public OperateScriptServerResponseModel uploadScript(String accessToken,
|
||||
String scriptName, String scenarioModel,
|
||||
CommonsMultipartFile[] paramFiles) {
|
||||
MultipartRequest multipartRequest,MultipartFile[] paramFiles) {
|
||||
String url = this.getBaseUrl() + "/uploadScript" + "/" + scriptName;
|
||||
List<String> stringPart = new LinkedList<String>();
|
||||
stringPart.add(scenarioModel);
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.bench4q.web.masterMessager.PluginMessager;
|
|||
import org.bench4q.web.validation.PluginValidation;
|
||||
import org.bench4q.web.validation.ValidateResponseModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.bench4q.web.extractObjectFromXml.ObjectXmlExchange;
|
|||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Component
|
||||
public class CommunicateWithMaster {
|
||||
|
@ -77,8 +77,8 @@ public class CommunicateWithMaster {
|
|||
|
||||
public HttpResponse uploadScriptWithParamFiles(String accessToken,
|
||||
String scriptName, RunScenarioModel runScenarioModel,
|
||||
CommonsMultipartFile[] paramFiles) {
|
||||
String url = masterAddress + "RecordScript/uploadScript/" + scriptName;
|
||||
MultipartFile[] paramFiles) {
|
||||
String url = masterAddress + "script/uploadScript/" + scriptName;
|
||||
List<String> stringPart = new LinkedList<String>();
|
||||
stringPart.add(MarshalHelper.tryMarshal(runScenarioModel));
|
||||
try {
|
||||
|
|
|
@ -154,11 +154,8 @@ function submitScriptByAjax(scriptModel) {
|
|||
var formData = new FormData();
|
||||
var filesDiv = $("input[type=file]");
|
||||
console.log(filesDiv);
|
||||
if (filesDiv.length == 0) {
|
||||
formData.append("paramFiles", new Array[], "");
|
||||
} else {
|
||||
if (filesDiv.length != 0) {
|
||||
for ( var i = 0; i < filesDiv.length; i++) {
|
||||
|
||||
formData.append("paramFiles", filesDiv[i].files[0],
|
||||
filesDiv[i].files[0].name);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue