webwork环境搭建

打算从头开始webwork学习,第一步先搭建起webwork吧!
参考文献:webwork in action

目录结构:
[img]F:\images\1.jpg[/img]

配置:
web.xml
[code]
<?xml version="1.0" encoding="ISO-8859-1"?>

<!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>webwork</display-name>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>


<!-- webwork -->
<servlet>
<servlet-name>webwork</servlet-name>
<servlet-class>
com.opensymphony.webwork.dispatcher.ServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>webwork</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>

<!-- Tags -->
<taglib>
<taglib-uri>webwork</taglib-uri>
<taglib-location>
/WEB-INF/lib/webwork-2.1.7.jar
</taglib-location>
</taglib>
</web-app>
[/code]
xwork.xml
[code]
<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
"http://www.opensymphony.com/xwork/xwork-1.0.dtd">
<xwork>
<include file="webwork-default.xml"/>
<package name="default" extends="webwork-default">
<default-interceptor-ref name="defaultStack"/>
<action name="helloWorld" class="webwork.action.HelloWorld">
<result name="success">/default/hello.jsp</result>
</action>
</package>
</xwork>
[/code]
webwork.properties
[code]
webwork.tag.altSyntax = true
[/code]

action:
[code]
/*
* Created on 2006-10-12
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package webwork.action;
import com.opensymphony.xwork.Action;
/**
* @author Liu
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class HelloWorld implements Action {
private String message;
public String execute() {
message = "Hello, World!";
return SUCCESS;
}

public String getMessage() {
return message;
}
}
[/code]

jsp:
index.jsp
[code]
<html>
<head><title>webwork</title></head>
<body>
hello,webwork!
<body>
</html>
[/code]

hello.jsp
[code]
<%@ taglib prefix="ww" uri="webwork" %>
<html>
<head>
<title>Hello Page</title>
</head>
<body>
The message generated by my first action is:
<ww:property value="message"/>
</body>
</html>
[/code]

运行结果:
[img]F:/images/2.jpg[/img]
[img]F:/images/3.jpg[/img]

运行成功!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值