裸机 wicket/tomcat HelloWorld 示例
我是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经能够使它工作:
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
很难判断您的应用程序出了什么问题。我创建了一个快速示例,如下所示来测试配置:
选择
wicket-archetype-quickstart
(我的机器上为 189),版本 1.4.15...浏览到
http://localhost: 8080/wicket
并且该应用程序运行起来就像一个魅力。这些是所需的库:
来源:
我的来源结构是:
我理解你不想使用maven(如果你正在学习并尝试从头开始做任何事情,那就太好了),但没有任何进一步的信息,我只能建议你看看我上面的工作示例。您的第一个库集似乎不完整。
It's hard to tell what is wrong with your application. I created a quick sample as follows to test the configuration:
Choosing
wicket-archetype-quickstart
(189 on my machine), version 1.4.15...Browsing to
http://localhost:8080/wicket
and the application works like a charm.And these are the libraries required:
Sources:
And my source structure is:
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.