前端api接口:export function createAnnouncement(data) {
return request({
url: '/announcement/post',
method: 'post',
data })
后端用@RequestBody获取的话会直接警告:
2020-03-19 10:32:07.460 WARN 12056 --- [nio-8090-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: I/O error while reading input message; nested exception is org.apache.catalina.connector.ClientAbortException: java.io.EOFException: Unexpected EOF read on the socket]
2条答案
按热度按时间oknrviil1#
也许是这个问题 3020
jaql4c8m2#
3020提供了解决方案,但是会引出另外一个问题,模拟接口和代理接口共存时,只能用localhost访问,用IP地址不能访问,结局方案如下:
app.use('/dev-api/vue-element-admin/', bodyParser.json())
app.use('/dev-api/vue-element-admin/', bodyParser.urlencoded({
extended: true
}))
只有mock的接口才用node body解析,proxy代理接口不要解析