Cannot forward to error page for request [/wechat/portal] as the response has already been commit
6198 단어 J2EE
1. 문제 설명
최근 Spring Boot을 사용하여 웹 프레임워크를 구축하는 과정에서 이러한 문제가 발생했습니다. 이 인터페이스는 위챗 서버의 서명 검사를 받았지만 요청할 때 ERROR을 보고했습니다.
2018-05-30 13:56:14.265 ERROR - Cannot forward to error page for request
[/wechat/portal/hdd] 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 (o.s.boot.web.support.ErrorPageFilter:210) [http-nio-8080-exec-6]
2. 솔루션
로그 알림을 보려면 false
com.ibm.ws.webcontainer.invokeFlushAfterService
를 설정해야 합니다. @Bean
public ErrorPageFilter errorPageFilter() {
return new ErrorPageFilter();
}
@Bean
public FilterRegistrationBean disableSpringBootErrorFilter(ErrorPageFilter filter) {
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
filterRegistrationBean.setFilter(filter);
filterRegistrationBean.setEnabled(false);
return filterRegistrationBean;
}
3. 깊이 파고들다
인터페이스 코드 부착:
@GetMapping(produces = "text/plain;charset=utf-8")
public String authGet(@RequestParam(name = "signature", required = false) String signature,
@RequestParam(name = "timestamp", required = false) String timestamp,
@RequestParam(name = "nonce", required = false) String nonce,
@RequestParam(name = "echostr", required = false) String echostr) {
return authGet(signature, timestamp, nonce, echostr, null);
}
@ResponseBody
@GetMapping(value = "/{channel}", produces = "text/plain;charset=utf-8")
public String authGet(@RequestParam(name = "signature", required = false) String signature,
@RequestParam(name = "timestamp", required = false) String timestamp,
@RequestParam(name = "nonce", required = false) String nonce,
@RequestParam(name = "echostr", required = false) String echostr,
@PathVariable(name = "channel") String channel) {
log.info("
[{}, {}, {}, {},{}]", signature, timestamp, nonce, echostr, channel);
if (StringUtils.isAnyBlank(signature, timestamp, nonce, echostr)) {
throw new IllegalArgumentException(" , !");
}
WxMpService wxMpService = oldHxWeChatService;
if (channel != null) {
wxMpService = hxWeChatService;
}
if (wxMpService.checkSignature(timestamp, nonce, signature)) {
return echostr;
}
return " ";
}
솔루션: response 출력 흐름 또는 @ResponseBody 사용
response.getWriter().print(echostr);
@responseBody
메모의 역할은 controller
방법으로 반환된 대상을 적당한 변환기를 통해 지정된 형식으로 변환한 후 response body
JSON 데이터나 XML 데이터로 되돌려 주는 데 사용하는데, 주의해야 할 것은 이 메모를 사용한 후에 프로세서를 시도하지 않고 흐름에 직접 기록하는 것이다. 그의 효과는 response
를 통해 지정된 형식의 데이터를 출력하는 것과 같다.return echostr
spring을 사용하면 대응하는 보기를 찾을 수 없지만 보기를 찾을 수 없고spring은 errorPage
로 넘어갔지만 프로젝트에 설정이 없음errorPage
으로 404.이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
layui- 동적 렌더링 드롭다운 상자 (백그라운드에서 드롭다운 상자 값 가져오기) & 드롭다운 상자 기본 선택 설정동적 렌더 드롭다운 상자 드롭다운 상자 기본 선택 설정...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.