2014-02-16 60 views
0

響應寫時,我有一個小門頁是這樣的:IndexOutOfBoundException試圖在檢票口

public final class Services extends WebPage { 
    public Services() { 
     super(); 
    } 

    public Services(PageParameters params) { 
     StringValue serviceType = params.get("name"); 
     if("report".equals(serviceType.toString())) { 
      this.getResponse().write("HelloWorld"); 
     } 
    } 
} 

,它的HTML是空的。 當我把這個頁面的URL我看到這個錯誤

Index: 0, Size: 0 
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 
    at java.util.ArrayList.rangeCheck(ArrayList.java:604) 
    at java.util.ArrayList.get(ArrayList.java:382) 
    at java.util.Collections$UnmodifiableList.get(Collections.java:1211) 
    at org.apache.wicket.markup.Markup.get(Markup.java:130) 
    at org.apache.wicket.Component.internalRender(Component.java:2356) 
    at org.apache.wicket.Component.render(Component.java:2307) 
    at org.apache.wicket.Page.renderPage(Page.java:1010) 
    at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:121) 
    at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:271) 
    at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:165) 
    at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:861) 
    at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) 
    at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261) 
    at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218) 
    at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289) 
    at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259) 
    at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201) 
    at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282) 
... 

我不知道是不是真的有什麼是錯誤的,我簡單的小門頁。

回答

3

Wicket曾經期望在代碼的關聯HTML模板中有一些標記。這是你的異常的鼻祖線是Component.class看到

private final void internalRender() 
{ 
... 
    MarkupElement elem = markup.get(0); 
... 
} 

該代碼獲取相關標記的「根」元素。沒有任何標記的代碼在Wicket中是無法識別的。

提示:如果您只是想處理請求,請安裝可共享資源或除頁面外的其他一些資源。