I am trying to check the contents of some files via the web interface and use the answer to enable / disable some other functions ... for example, the save button. I got to sending and processing files (cut through), but I can not get my answer to work correctly.
Problem: When responding, it tries to force the user to upload a file with the contents of the response. I just want to convey the response to the success function that needs to be processed.
JS function code:
function validateCopybook() { //submit values. console.log("validating"); if (this.getForm().isValid()) { this.getForm().submit({ url : 'batch/validateCopybook.json', waitMsg : 'Validating...', success : function(form, action) { this.msg('Success', 'Processed file on the server'); } }); } }
Server Side Code:
public ModelAndView validateCopybook(HttpServletRequest request, HttpServletResponse response) throws Exception { // Check whether we're dealing with a multipart request String contentHeader = request.getHeader("content-type"); boolean isMultipart = (contentHeader != null && contentHeader.indexOf("multipart/form-data") != -1); if (isMultipart == false) { return Helper.errorResponse("not multipart"); } else { DefaultMultipartHttpServletRequest reqM = (DefaultMultipartHttpServletRequest) request; MultiValueMap<String, MultipartFile> fileMap = reqM.getMultiFileMap(); MultipartFile copyIn = fileMap.get("copy-path-in").get(0); MultipartFile copyOut = fileMap.get("copy-path-out").get(0); } System.out.println(response.getContentType()); response.setContentType("application/json"); ModelAndView mav = Helper.successResponse("success"); return mav; }
The answer is back:
ModelAndView: reference to view with name 'json'; model is {model={data={"success":true,"info":"success","dataLength":0,"data":[]}}}
Any ideas?
source share