请教wicket

06-06-12 eoeac
按照官方主页http://wicket.sourceforge.net/ExampleHelloWorld.html写了一个简单的Demo,但一直配置不成功。很想知道原因,希望大家能帮助我一下。

使用IDE为eclipse3.1+MyEclispe4.03

wicket版本为1.2

HelloWorld.html

<html>
<body>
    <span wicket:id="message">Message goes here</span>
</body>
</html>
<p>

HelloWorldApplication.java

package com.test;

import wicket.protocol.http.WebApplication;

public class HelloWorldApplication extends WebApplication {
    public HelloWorldApplication() {
    }
    
    public Class getHomePage() {
        return HelloWorld.class;
    }
}
<p>

HelloWorld.java

package com.test;

import wicket.markup.html.WebPage;
import wicket.markup.html.basic.Label;

public class HelloWorld extends WebPage {
    public HelloWorld() {
        add(new Label("message", "Hello World!"));
    }
}
<p>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <display-name>test</display-name>
    <servlet>
        <servlet-name>HelloWorldApplication</servlet-name>
        <servlet-class>wicket.protocol.http.WicketServlet</servlet-class>
        <init-param>
          <param-name>applicationClassName</param-name>
          <param-value>com.test.HelloWorldApplication</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>HelloWorldApplication</servlet-name>
        <url-pattern>/app/*</url-pattern>
    </servlet-mapping>
</web-app>
<p>

访问路径:http://localhost/test/app

错误信息:

Unexpected RuntimeException

WicketMessage: Markup of type 'html' for component 'com.test.HelloWorld' not found. Enable debug messages for wicket.util.resource to get a list of all filenames tried:[Page class = com.test.HelloWorld, id = 0]Root cause:wicket.markup.MarkupNotFoundException: Markup not found. Component class: com.test.HelloWorld Enable debug messages for wicket.util.resource to get a list of all filenames tried at wicket.markup.MarkupCache.getMarkupStream(MarkupCache.java:116) at wicket.MarkupContainer.getAssociatedMarkupStream(MarkupContainer.java:825) at wicket.Page.onRender(Page.java:857) at wicket.Component.render(Component.java:1511) at wicket.Page.renderPage(Page.java:411) at wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:226) at wicket.request.compound.DefaultResponseStrategy.respond(DefaultResponseStrategy.java:49) at wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond(AbstractCompoundRequestCycleProcessor.java:66) at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:852) at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:879) at wicket.RequestCycle.step(RequestCycle.java:960) at wicket.RequestCycle.steps(RequestCycle.java:1034) at wicket.RequestCycle.request(RequestCycle.java:453) at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:215) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) at java.lang.Thread.run(Thread.java:534)Complete stack:wicket.markup.MarkupNotFoundException: Markup of type 'html' for component 'com.test.HelloWorld' not found. Enable debug messages for wicket.util.resource to get a list of all filenames tried:[Page class = com.test.HelloWorld, id = 0] at wicket.MarkupContainer.getAssociatedMarkupStream(MarkupContainer.java:836) at wicket.Page.onRender(Page.java:857) at wicket.Component.render(Component.java:1511) at wicket.Page.renderPage(Page.java:411) at wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:226) at wicket.request.compound.DefaultResponseStrategy.respond(DefaultResponseStrategy.java:49) at wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond(AbstractCompoundRequestCycleProcessor.java:66) at wicket.RequestCycle.doProcessEventsAndRespond(RequestCycle.java:852) at wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:879) at wicket.RequestCycle.step(RequestCycle.java:960) at wicket.RequestCycle.steps(RequestCycle.java:1034) at wicket.RequestCycle.request(RequestCycle.java:453) at wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:215)

Page

[Page class = com.test.HelloWorld, id = 0]:

# Path Size Type Model Object

1 message 456 bytes wicket.markup.html.basic.Label Hello World!

谢谢大家!!!

banq
2006-06-12 21:08
>MarkupNotFoundException: Markup of type 'html' for component 'com.test.HelloWorld' not found

对应组件'com.test.HelloWorld' 的html类型配置项没有。

eoeac
2006-06-14 13:25
首先非常感谢banq的回复!

再请问一下该类型配置项应该怎样创建?刚刚接触wicket,在它的官方页面也没找到相应的配置方法.

lovefly_zero
2006-06-23 10:37
你写的这些都是对的,你要把这些文件放在同一个包下才可以,我研究这个也遇到过这个错误..

Wicket真的好用,用心学吧

eoeac
2006-06-28 21:06
请问你所说的同一个包是什么意思,我已经将所有的class文件都打入com.test包下了,难道要把web.xml文件也放到com.test下吗?

希望能详细说明一下,在此非常感谢!

eoeac
2006-06-29 13:02
问题已经解决,原来需要把.html文件也放到相应的包路径下,谢谢大家了~

猜你喜欢