1

단일보기 응용 프로그램 vaadin 7.7.7, spring-boot 1.5 사용자로부터 uri fragment https :/tld/#! category-name-1을 확인하고 범주 쇼 항목을 존재하고 난 오류가 발생했습니다 (임베디드 바람둥이와) 업데이트 스프링 부팅 1.5 angel이라는 7.7.7 후하지 않을 경우vaadin + spring boot : 요청시 오류 페이지로 전달할 수 없음

VaadinService.getCurrentResponse().sendError(404, "page not found!"); 

하지만 :

Cannot forward to error page for request [/vaadinServlet/UIDL/] 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 

어떻게 내가 만약 angel에서 HTTP 오류 페이지를 보낼 수 있습니다 사용자에게? ErrorPageCutomizer.java

@Component 
public class ErrorPageCutomizer implements EmbeddedServletContainerCustomizer { 
    @Override 
    public void customize(ConfigurableEmbeddedServletContainer container) { 
     container.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/error/404")); 
     container.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500")); 
    } 
} 

RestController.java

import org.springframework.boot.autoconfigure.web.ErrorController; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RestController; 

@RestController 
public class ErrorHandlingController implements ErrorController { 

    private static final String PATH = "/error"; 

    @RequestMapping(value = PATH + "/404") 
    public String error404() { 
     return "<div style='font-weight:bold; margin-top:200px; text-align:center; font-size:160%;'>Page not found...<br><a href=\"https://tld\">to home</a></div>"; 
    } 

    @RequestMapping(value = PATH + "/500") 
    public String error500() { 
     return "<div style='font-weight:bold; margin-top:200px; text-align:center; font-size:160%;'>500 Internal server error...</div>"; 
    } 

    @Override 
    public String getErrorPath() { 
     return PATH; 
    } 
} 

답변

0

Soliution했다 :

@Configuration 
public class AppInitializer implements WebApplicationInitializer { 

    @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; 
    } 
} 
+1

을 의미합니다. Vaadin 8.0.5 및 스프링 부트 1.5.3에서 작동하지 않습니다. –

-1

당신이 SystemMessagesProvider을 시도했습니다. 그 프로 바이더에서 당신은 다양한 오류에 대한 errorUrl을 정의 할 수 있습니다 :

public class YourServlet extends VaadinServlet 
{ 
    @Override 
    protected void servletInitialized() throws ServletException 
    { 
     super.servletInitialized(); 

     getService().setSystemMessagesProvider(new SystemMessagesProvider() 
     { 
      @Override 
      public SystemMessages getSystemMessages(SystemMessagesInfo systemMessagesInfo) 
      { 
       final CustomizedSystemMessages c = new CustomizedSystemMessages(); 
       final String errorUrl = "<url to errorpage>"; 
       c.setSessionExpiredURL(errorUrl); 
       c.setSessionExpiredNotificationEnabled(false); 

       c.setAuthenticationErrorURL(errorUrl); 
       c.setAuthenticationErrorNotificationEnabled(false); 

       c.setCommunicationErrorURL(errorUrl); 
       c.setCommunicationErrorNotificationEnabled(false); 

       c.setCookiesDisabledURL(errorUrl); 
       c.setCookiesDisabledNotificationEnabled(false); 

       c.setInternalErrorURL(errorUrl); 
       c.setInternalErrorNotificationEnabled(false); 

       c.setSessionExpiredURL(errorUrl); 
       c.setSessionExpiredNotificationEnabled(false); 
       return c; 
      } 
     }); 
    } 
+0

질문이었다 '어떻게 사용자에게 만약 angel에서 HTTP 오류 페이지를 보낼 수 있습니다?'. '봄에 오류 페이지를 보내려면 어떻게해야합니까?'가 아닙니다. 그리고 제 제안은 바로 이것입니다. 나는 왜 내 대답이 격하했는지에 대한 설명에 감사 할 것이다. –

+0

내가 보내는 경우 : VaadinService.getCurrentResponse(). sendError (404, "페이지를 찾을 수 없습니다!"); 콘솔에서 다음 오류가 발생했습니다 : "응답이 이미 커밋되었으므로 요청 [/]에 대한 오류 페이지로 전달할 수 없습니다. 결과적으로 응답의 상태 코드가 잘못되었을 수 있습니다. 응용 프로그램이 WebSphere Application Server에서 실행중인 경우 com.ibm.ws.webcontainer.invokeFlushAfterService를 false로 설정하여이 문제점을 해결할 수 있습니다. " sys 메시지를 사용자 정의하지 않습니다. –