裸机 wicket/tomcat HelloWorld 示例

发布于 2024-10-18 21:53:20 字数 2273 浏览 2 评论 0原文

我是 wicket 新手,想从 wicket-examples 部署简单的众所周知的 helloworld,但没有 IDE、ant 或 maven。我所做的:

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">

    <display-name>Wicket Examples</display-name>
    <filter>
        <filter-name>HelloWorldApplication</filter-name>
        <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
          <param-name>applicationClassName</param-name>
          <param-value>HelloWorldApplication</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>HelloWorldApplication</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

HelloWorld.html:

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

HelloWorld.java:

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

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

HelloWorldApplication.java:

import org.apache.wicket.protocol.http.WebApplication;

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

wicket-HelloWorld.war:

WEB-INF/
WEB-INF/web.xml
WEB-INF/classes/
WEB-INF/classes/HelloWorldApplication.class
WEB-INF/classes/HelloWorld.class
WEB-INF/classes/HelloWorld.html
WEB-INF/lib/
WEB-INF/lib/wicket-1.4.15.jar
WEB-INF/lib/slf4j-api.jar

我不确定这个简单的示例是否需要 slf4j-api.jar

当部署到 tomcat < a href="http://localhost:8080/wicket-HelloWorld/" rel="nofollow">http://localhost:8080/wicket-HelloWorld/ 给出:

请求的资源 () 不可用

什么我做错了吗?

I'm a wicket newbie and would like to deploy the simple well-known helloworld from wicket-examples but without IDE, ant or maven. What I've done:

web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
         version="2.4">

    <display-name>Wicket Examples</display-name>
    <filter>
        <filter-name>HelloWorldApplication</filter-name>
        <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
          <param-name>applicationClassName</param-name>
          <param-value>HelloWorldApplication</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>HelloWorldApplication</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

HelloWorld.html:

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

HelloWorld.java:

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

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

HelloWorldApplication.java:

import org.apache.wicket.protocol.http.WebApplication;

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

wicket-HelloWorld.war:

WEB-INF/
WEB-INF/web.xml
WEB-INF/classes/
WEB-INF/classes/HelloWorldApplication.class
WEB-INF/classes/HelloWorld.class
WEB-INF/classes/HelloWorld.html
WEB-INF/lib/
WEB-INF/lib/wicket-1.4.15.jar
WEB-INF/lib/slf4j-api.jar

I'm not sure if I need slf4j-api.jar for this simple example

When deployed to tomcat http://localhost:8080/wicket-HelloWorld/ gives:

The requested resource () is not available

What I'm doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

远山浅 2024-10-25 21:53:20

我已经能够使它工作:

1.-我添加了 slf4j-jdk14.jar。行动奖励第 15 章中的曼宁威克特 (Manning Wicket) 是错误的。它只告诉添加 slf4j-api.jar

2.- wicket-1.4.15.jar 必须位于 WEB-INF/lib 中。尝试将其包含在shared.loader或$CATALINA_BASE/lib下的catalina.properties中对我来说不起作用;尽管一些网站推荐这些地方作为在运行时包含库的替代方案。

我几乎没有发现仅使用 javac 构建 wicket 应用程序的文档。我认为有足够经验的人应该写一些操作方法。您几乎被迫使用 Maven 来编写 wicket 中最简单的应用程序

问候并感谢所有人的帮助

Francesc

I've been able to make it work:

1.- I added slf4j-jdk14.jar. Manning Wicket in action bonus chapter 15 was wrong. It tells only to add slf4j-api.jar

2.- wicket-1.4.15.jar MUST BE in WEB-INF/lib. Trying to include it in catalina.properties under shared.loader or $CATALINA_BASE/lib doesn't work for me; despite some webs recommending these places as alternatives to include libraries at runtime.

I've found almost no documentation to build wicket apps using only javac. I think somebody experienced enough should write a little HOW-TO. You're almost forced to use Maven to program even the simplest application in wicket

Regards and thanks to all for the help

Francesc

躲猫猫 2024-10-25 21:53:20

很难判断您的应用程序出了什么问题。我创建了一个快速示例,如下所示来测试配置:

$ mvn archetype:generate

选择 wicket-archetype-quickstart (我的机器上为 189),版本 1.4.15...

$ mvn tomcat:run

浏览到 http://localhost: 8080/wicket 并且该应用程序运行起来就像一个魅力。

$ mvn package
$ cd target/wicket-1.0-SNAPSHOT/WEB-INF/lib

这些是所需的库:

  • log4j-1.2.14.jar
  • slf4j-api-1.5.8.jar
  • slf4j-log4j12-1.5.8.jar
  • wicket-1.4.15.jar

来源:

$ cd src/main
$ tree

我的来源结构是:

.
|-- java
|   `-- com
|       `-- blogspot
|           `-- nurkiewicz
|               |-- HomePage.html
|               |-- HomePage.java
|               `-- WicketApplication.java
|-- resources
|   `-- log4j.properties
`-- webapp
    `-- WEB-INF
        `-- web.xml

我理解你不想使用maven(如果你正在学习并尝试从头开始做任何事情,那就太好了),但没有任何进一步的信息,我只能建议你看看我上面的工作示例。您的第一个库集似乎不完整。

It's hard to tell what is wrong with your application. I created a quick sample as follows to test the configuration:

$ mvn archetype:generate

Choosing wicket-archetype-quickstart (189 on my machine), version 1.4.15...

$ mvn tomcat:run

Browsing to http://localhost:8080/wicket and the application works like a charm.

$ mvn package
$ cd target/wicket-1.0-SNAPSHOT/WEB-INF/lib

And these are the libraries required:

  • log4j-1.2.14.jar
  • slf4j-api-1.5.8.jar
  • slf4j-log4j12-1.5.8.jar
  • wicket-1.4.15.jar

Sources:

$ cd src/main
$ tree

And my source structure is:

.
|-- java
|   `-- com
|       `-- blogspot
|           `-- nurkiewicz
|               |-- HomePage.html
|               |-- HomePage.java
|               `-- WicketApplication.java
|-- resources
|   `-- log4j.properties
`-- webapp
    `-- WEB-INF
        `-- web.xml

I understand you don't want to use maven (great if you are learning and trying to do anything from scratch), but without any further information I can only advice you to look at my working example above. First of your libraries set seems to be incomplete.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文