Multipartfile file If there are no files to upload how to solve

Source: Internet
Author: User

Method in Controller

 Public String excelinsertteachers (multipartfile file,httpservletrequest request, HttpSession session, HttpServletResponse response)            throws  illegalstateexception, IOException {}

This method may go many times, but there is no upload file operation, then this method will have an exception, how to solve it?

 PublicString excelinsertteachers (httpservletrequest request, HttpSession session, HttpServletResponse Response) throwsIllegalStateException, IOException {multipartfile file=NULL; BooleanIsmultipart =servletfileupload.ismultipartcontent (Request); if(ismultipart) {multiparthttpservletrequest multipartrequest=webutils.getnativerequest (Request, multiparthttpservletrequest.class); File= Multipartrequest.getfile ("Multipartfile"); }

Get to the method to determine whether there is currently a file commit, and if so, to do the read file operation.

I asked a predecessor, and he meant it. You can specify that the current existence does not exist by setting parameters .... But I can't find it. Scratching his heads. jpg

If a friend knows other ways, you can tell me other ways, thank you for scratching your heads. gif.

Multipartfile file If there are no files to upload how to solve

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.