(GAE/J에서 실행) 내 아파치 개찰구 웹 응용 프로그램의 예를 들어, 사용자가 존재하지 않는 페이지를 방문하려고하면 소개존재하지 않는 페이지에 액세스하려고 할 때 유효한 Wicket 페이지로 리디렉션 할 수 있습니까?
:
이http://[MyURL]/admin/PageSubscribeX
웹 프레임 워크는 로그 다음과 같은 경고 :
org.apache.wicket.core.util.lang.WicketObjects resolveClass: Could not resolve class [[...].admin.PageSubscribeX]
java.lang.ClassNotFoundException: [...].admin.PageSubscribeX
at com.google.appengine.runtime.Request.process-78915baf06af5f31(Request.java)
at java.lang.Class.forName(Class.java:133)
at org.apache.wicket.application.AbstractClassResolver.resolveClass(AbstractClassResolver.java:108)
at org.apache.wicket.core.util.lang.WicketObjects.resolveClass(WicketObjects.java:71)
at org.apache.wicket.core.request.mapper.AbstractComponentMapper.getPageClass(AbstractComponentMapper.java:139)
at org.apache.wicket.core.request.mapper.PackageMapper.parseRequest(PackageMapper.java:148)
...
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458)
at java.lang.Thread.run(Thread.java:679)
및 GAE/J 오류 404 페이지 텍스트 Error: NOT_FOUND
로 응답합니다.
현재 GAE/J를 사용 중입니다. "URL에 대해 서블릿 매핑이 정의되지 않은 경우 404 응답 페이지를 사용자 정의 할 수 없습니다."
내 질문
에는 서블릿 매핑은 URL에 대해 정의되지 않은 경우 I는 응답 개찰 페이지를 지정할 수있는 방법이 있나요? 다른 방법으로, 내가 선택한 Wicket 페이지에 "모든 URL을 찾을 수 없음"을 매핑하도록 정의 할 수있는 서블릿 매핑이 있습니까?
내 소프트웨어 환경은 다음과 같습니다
- 개찰구 : 6.2.0
- GAE/J : 1.7.3
- 자바 : 1.6.0_37.
는, 나는 다음을 시도 @biziclop의 의견에 따라 시도
실패,하지만이 실패했습니다. 내가 가진 모든 내 오류 페이지 PageError 모든 시간을 보여주는되었다 .... 내 WebApplication#init()
에서
내 코드이었다
ICompoundRequestMapper crmRoot = getRootRequestMapperAsCompound();
URLNotFoundMapper mapperURLNotFound = new URLNotFoundMapper(null,
PageError.class);
crmRoot.add(mapperURLNotFound);
setRootRequestMapper(crmRoot);
나의 새로운 매퍼 URLNotFoundMapper
이
/**
* This mapper class is intended to be the mapper of last resort, to be used
* if all other mappers cannot handle the URL of the current request.
* <br/>
* This mapper will cause a defined (error) page to be shown.
*/
public class URLNotFoundMapper extends BookmarkableMapper
{
private IRequestMapper m_rmRoot = null;
private Class<? extends IRequestablePage> m_classPage = null;
/**
* Constructor.
* @param rmRoot
* The application's previous root request mapper.
* If this is <code>null</code> then it is ignored.
* @param clError
* The class of the page which should handle erroneous requests.
* This must not be <code>null</code>.
*/
public URLNotFoundMapper(IRequestMapper rmRoot,
final Class<? extends IRequestablePage> clError)
{
m_rmRoot = rmRoot;
m_classPage = clError;
}
/**
* Use this mapper as the last option.
* So let all other mappers try to handle the request first.
* @param request
* The request.
* @return
* The score of the application's previous root request mapper.
*/
@Override
public int getCompatibilityScore(Request request)
{
return Integer.MIN_VALUE;
}
/**
* This method returns an <code>IRequestHandler</code> for the bookmarkable
* error page.
* @param request
* @return
* An <code>IRequestHandler</code> capable of processing a bookmarkable
* request.
*
*/
@Override
public IRequestHandler mapRequest(Request request)
{
IRequestHandler rhResult = null;
if (m_rmRoot != null)
rhResult = m_rmRoot.mapRequest(request);
if (rhResult != null)
rhResult = null; // Another mapper can handle this
else
{
rhResult = processBookmarkable(m_classPage, null);
}
return rhResult;
}
@Override
public Url mapHandler(IRequestHandler requestHandler)
{
Url urlResult = null;
if (m_rmRoot != null)
urlResult = m_rmRoot.mapHandler(requestHandler);
if (urlResult != null)
urlResult = null; // Another mapper can handle this
else
{
PageInfo info = new PageInfo();
UrlInfo urlInfo = new UrlInfo(new PageComponentInfo(info, null),
m_classPage, null);
urlResult = buildUrl(urlInfo);
}
return urlResult;
}
/**
* @return
* The URL info for the bookmarkable error page.
*/
@Override
protected UrlInfo parseRequest(Request request)
{
UrlInfo uiResult = null;
uiResult = new UrlInfo(null, m_classPage, null);
return uiResult;
}
}
분명히 가능해야하며 스택 추적을 보면 아마 매퍼 레벨에서이를 처리하는 것이 가장 좋습니다. – biziclop
@biziclop "오류 페이지"요소 또는 다른 것을 포함하도록 web.xml 파일을 수정한다는 의미입니까? –
프로그래밍 방식으로 말하자면 여기에 나온대로 (https://cwiki.apache.org/WICKET/request-mapping.html). 마지막 코드 스 니펫에서는 루트 요청 매핑 프로그램을 사용자 지정 구현으로 바꾸는 방법을 보여줍니다. 여기에서로드하려는 페이지 클래스와시기를 완전히 제어 할 수 있습니다. – biziclop