[Download Files Error] HttpMessageNotWritableException IllegalStateException: COMPLETED

When you click to download a file, the error prompt is mainly reported. You can still download it, but since an error is thrown, go to find it. Finally, I found an error in the operation…

org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver : Failure while trying to resolve exception [org.springframework.http.converter.HttpMessageNotWritableException]
java.lang.IllegalStateException: COMPLETED
......
org.eclipse.jetty.server.HttpChannel : /file-api/downloadFile
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class com..filepreview.entity.DataPackage] with preset Content-Type 'application/x-msdownload;charset=utf-8'
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) ~[spring-webmvc-5.3.3.jar:5.3.3]
......
org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class com..filepreview.entity.DataPackage] with preset Content-Type 'application/x-msdownload;charset=utf-8'

See the main tips:

Request processing failed; The nested exception is org.springframework.http.converter.httpmessagenotwritableexception: there is no converter for [class com. Filepreview. Entity. Datapackage] whose default content type is “applicationx msdownload”; Character set = UTF-8 ‘

So I see the keyword: datapackage, which is the encapsulated data return

The download file I thought of was actually a stream transmission, so I deleted this package and changed the method to void type

Abnormal output:

Normal after modification:

Similar Posts: