The Spring interface is affected by the request header

Generally, the back-end interface returns json data, and the front-end uses Accept=application/json. If the data stream is accepted, Accept=text/event-stream, Spring will decide how to respond to the data according to the Accept type of the request. If it is a stream, the data you respond can only be String.

If there is Accept=text/event-stream in the request header, Spring will read this value, then go through the corresponding process, and write String type data into the stream. At this time, if the backend returns a type A, expect object a If it is converted into a json string, an error will be reported that type A cannot be converted into a String.

Guess you like

Origin blog.csdn.net/tales522/article/details/131584131