springboot跳转页面404的问题

今天测试的时候出现了这个问题:

Cannot forward to error page for request [/] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false

检查发现服务端接口都设置了,请求方式也对着的,但就是没有执行接口里的任何代码就抛出该提示。后面发现是增加了这么一个代码:

@RequestParam(name = "id") 

加上这段代码之后,若请求参数里没有 id 参数,服务端会认为该请求不是请求的这个接口,导致服务端未找到对应的接口来处理客户端请求,所以报404,或者尝试跳转到错误处理页面。

处理方法:

1.修改客户端请求的参数,与服务端接口一致;

2.可以删除 @RequestParam 标注,这样下次参数名弄错了,服务端也有明显的提示。

 

posted @ 2022-08-23 15:42  我是包子  阅读(974)  评论(0编辑  收藏  举报