We still don't know why the MultipartFile file that we stepped on that day was null

The day before yesterday, the front-end brother secretly poked me and said that the file upload was wrong! Hurry up and change it!

As soon as I thought that the official address of this project had been released, I immediately got nervous and tried it locally. The parameters received in the background were empty, but after seeing that the code had not been modified for more than a month, I immediately looked at the front end with suspicious eyes. Bro.

After confirmation, the front end has not been touched for a long time, and the problem appeared suddenly, which is a bit strange.

1. First confirm whether the front end is abnormal

Basic confirmation is normal.

2. Check whether the request request in the interceptor is empty

When the breakpoint was finished and it was found that the MultipartHttpServletRequest that the request was forced to transfer could not get the object, Tumei's eyes became sharp.

After a wave on the Internet (two days later), I suddenly saw such a passage under the comments of an article

"The obtained request is null because the request has been consumed."

I thought it might be like this! ! !

As we all know, Spring boot needs to declare CommonsMultipartResolver as mutipartResolver when using MultipartFile

and saw the following prompt

After commenting this out and restarting, everything works fine!

But still don't know why this happens =. =, so be it

Guess you like

Origin blog.csdn.net/qq_16253859/article/details/106097236