2017-05-17 12 views
0

아파치 Tapestry를 사용하여 기존 웹 응용 프로그램을 구축했습니다. 몇 페이지를 제외하고 대부분의 응용 프로그램 기능을 사용하지 않습니다. 이 애플리케이션을 프로덕션 환경에서 실행하고 싶지만 사용되지 않는 페이지/URL을 404 오류 코드가있는 일부 오류 페이지로 리디렉션하고 싶습니다. 어디서 구성해야합니까? 나는 web.xml과 jboss-web.xml을 가지고있다. 일부 Tapestry 구성 파일에서이 작업을 수행해야합니까?Tapestry : 사용되지 않는 URL을 오류 페이지로 리디렉션하는 방법

답변

0

당신은 당신의 AppModule의 RequestHandler를 서비스, 즉에 RequestFilter 기여할 수 :

public void contributeRequestHandler(
       OrderedConfiguration<RequestFilter> configuration) 
{ 
    // Each contribution to an ordered configuration has a name, 
    // When necessary, you may set constraints to precisely control 
    // the invocation order of the contributed filter within the pipeline. 

    configuration.add("DeprecatedURLs", new RequestFilter() { 
     @Override 
     public boolean service(Request request, 
           Response response, 
           RequestHandler handler) throws IOException 
     { 
      String path = request.getPath(); 
      if (isDeprecated(path)) 
      { 
       response.sendError(404, "Not found"); 
       return; 
      } 

      return handler.service(request, response); 
     } 
    }, "before:*"); 
} 

가 주목하라 before:* 순서 제약, 그것은 RequestHandler's configuration에서 처음으로이 필터를 등록해야합니다.

+0

레거시 애플리케이션 코드에서 AppModule 또는 RequestHandler와 같은 것을 보지 못했습니다. 나는 태피스트리에 관해 정말로 모른다. TapestryFilter가 web.xml 파일에서 이와 같이 구성되어있는 것을 볼 수 있습니다. \t \t ResourcesApp \t \t <필터 클래스> org.apache.tapestry5.TapestryFilter \t \t <필터 매핑> \t \t ResourcesApp \t \t /* \t user1614862

+0

그것은 '해야한다 대신 AppModule''의 ResourcesAppModule', 필터 이름을 때문에'ResourcesAp p. Tapestry에 대해 잘 모르고 "기존"앱의 작업에 대해 조금 배우고 싶지 않은 경우에는 항상 앱 앞에 Apache 또는 NGINX와 같은 HTTP 프록시를 설정하고 그 대신 사용되지 않는 URL을 처리 할 수 ​​있습니다. –

+0

죄송합니다. 요청하신 Tapestry 버전은 무엇입니까? –