Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何创建所需的多部分文件的错误列表?_Java_Spring Mvc - Fatal编程技术网

Java 如何创建所需的多部分文件的错误列表?

Java 如何创建所需的多部分文件的错误列表?,java,spring-mvc,Java,Spring Mvc,我有一个包含图像列表的pojo。 在保存数据时,我没有选择任何要保存的图像,它会在控制器中返回类型未匹配错误。 我想设置包含多部分文件的图像列表。 我该怎么办 *****************************错误***************************************** [http-nio-8087-exec-11]错误com.iconicus.ERROR.restapp.RestResponseEntityExceptionHandler-400状态代码 or

我有一个包含图像列表的pojo。 在保存数据时,我没有选择任何要保存的图像,它会在控制器中返回类型未匹配错误。 我想设置包含多部分文件的图像列表。 我该怎么办

*****************************错误***************************************** [http-nio-8087-exec-11]错误com.iconicus.ERROR.restapp.RestResponseEntityExceptionHandler-400状态代码 org.springframework.validation.BindException:org.springframework.validation.BeanPropertyBindingResult:2个错误 字段“imageses[0]上的对象“productform”中存在字段错误。productimage:拒绝的值[];代码[typeMismatch.productform.imageses[0]。productimage,typeMismatch.imageses.productimage,typeMismatch.imageses.productimage,typeMismatch.productimage,typeMismatch.org.springframework.web.multipart.MultipartFile,typeMismatch];参数[org.springframework.context.support.DefaultMessageSourceResolvable:代码[productform.imageses[0].productimage,imageses[0].productimage];参数[];默认消息[imageses[0].productimage]];默认消息[未能将[java.lang.String]类型的属性值转换为属性“imageses[0].productimage]所需的类型[org.springframework.web.multipart.MultipartFile];嵌套异常为java.lang.IllegalStateException:无法将[java.lang.String]类型的值转换为所需类型属性“productimage”的[org.springframework.web.multipart.MultipartFile]:未找到匹配的编辑器或转换策略] 字段“imageses[1].productimage”上的对象“productform”中存在字段错误:拒绝值[];代码[typeMismatch.productform.imageses[1]。productimage,typeMismatch.productform.imageses.productimage,typeMismatch.imageses[1].productimage,typeMismatch.imageses.productimage,typeMismatch.org.springframework.web.multipart.MultipartFile,typeMismatch];参数[org.springframework.context.support.DefaultMessageSourceResolvable:代码[productform.imageses[1]。productimage,imageses[1]。productimage];参数[];默认消息[imageses[1].productimage]];默认消息[未能将[java.lang.String]类型的属性值转换为属性“imageses[1].productimage]的必需类型[org.springframework.web.multipart.MultipartFile];嵌套异常为java.lang.IllegalStateException:无法将[java.lang.String]类型的值转换为必需类型属性“productimage”的[org.springframework.web.multipart.MultipartFile]:未找到匹配的编辑器或转换策略] 位于org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:118) 位于org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121) 位于org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161) 位于org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128) 位于org.springframework.web.servlet.mvc.method.annotation.ServletinVaccableHandlerMethod.invokeAndHandle(ServletinVaccableHandlerMethod.java:114) 位于org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) 位于org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) 位于org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) 位于org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) 位于org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) 位于org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) 位于org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) 位于javax.servlet.http.HttpServlet.service(HttpServlet.java:661) 位于org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) 位于javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 位于org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 位于org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 位于com.iconicus.app.filter.FebnexFilter.doFilter(FebnexFilter.java:112) 位于org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 位于org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 位于org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 位于org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 位于org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 位于org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317) 位于org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) 位于org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) 位于org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 位于org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115) 位于org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) 位于org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) 在org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(filter
@RequestMapping(value = {"/updateimages"}, method = RequestMethod.POST)
@ResponseBody
public ApiResponse updateImages(@ModelAttribute("productform") Product productForm, HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException, SQLException, IOException {
    int responsedata = 0;
    try {
        productService.updateProductImages(productForm);
    } catch (ClassNotFoundException | SQLException ex) {
        logger.error(ex.getMessage(), ex);
    }
    return new ApiResponse(HttpStatus.OK, "Product Updated", String.valueOf(productForm.getId()), true);
}
private String id;
private String productname;
private String displayname;
private String productprice;
private String category;
private String subcategory;
private String categoryname;
private String subcategoryname;
private String taxcategory;
private String productweight;
private String description;
private String productsortorder;
private String productsku;
private String productshippingweight;
private String fixshippinginindia;
private String fixshippingworldwide;
private String allowcod;
private String visible;
private String active;
private String allowpurchaseind;
private String allowpurchaseworldwide;
private String freeshippinginindia;
private String freeshippingworldwide;
private String shippingasperweigth;
private String[] tags;
private ProductSeo productSeo;
private ProductOption productOption;
private List<ProductOptionSet> optionSets;
private List<ProductImages> imageses;
private List<ProductGroupTag> groupTag;
private List<ProductSeoDetail> seodetails;
private List<NoteForm> noteForm;
private String id;
private String productid;
private MultipartFile productimage;
private String productimagename;
private String imagetitle;
private String imagedescription;
private String imageseotitle;
private String imageseokeyword;
private String imageseodescription;
private String fileaction;
public String fileHandleController(HttpServletRequest request, @ModelAttribute Pojo pojo) {
    //check your request is multipart
    String contentType = request.getContentType();
    if(contentType != null && contentType.indexOf("multipart/form-data") > -1) {
        MultipartFile multipartFile = pojo.getFile();
        if(multipartFile.getSize() > 0){
            //to do
        }
    }

}