下载地址:http://this.oksonic.cn
开发工具:
Eclipse3.1.1 、 MyEclipse4.1.1 、 Tomcat5.5.17
开发步骤:
新建工程
名称为:test
拷贝 Tapestry4 相关的 jar 文件到项目的 lib 目录
修改 web.xml 文件,内容如下:
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
web-app
version
=
"2.4"
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"
>
<
servlet
>
<
servlet-name
>
test
</
servlet-name
>
<
servlet-class
>
org.apache.tapestry.ApplicationServlet
</
servlet-class
>
</
servlet
>
<
servlet-mapping
>
<
servlet-name
>
test
</
servlet-name
>
<
url-pattern
>
/app
</
url-pattern
>
</
servlet-mapping
>
</
web-app
>
新建
Home.java
到
src
目录,包为:
com.test
内容如下:
package com.test;
import org.apache.tapestry.html.BasePage;
public class Home extends BasePage {
public String getTest(){
return "Test成功!";
}
}
新建三个文件
hivemind.xml
、
Home.Page
、
test.application
到
WEB-INF
目录
test.application 文件的文件名称必须和项目名称一致,项目名称为 test 则文件名称为:test.application
文件内容如下:
hivemind.xml
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
module
name
=
"com.test"
version
=
"1.0.0"
>
</
module
>
Home.Page
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<!-- generated by Spindle, http://spindle.sourceforge.net -->
<page-specification>
<description>add a description</description>
</page-specification>
test.application
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<!-- generated by Spindle, http://spindle.sourceforge.net -->
<application name="test">
<meta key="org.apache.tapestry.page-class-packages" value="
com.test
"/>
</application>
新建 Home.html 文件到 WebRoot 目录下
内容如下:
<
span
jwcid
=
"@Insert"
value
=
"ognl:test"
/>
部署项目,使用以下路径访问:http://localhost/test/app ,成功的话则出现 Test成功!!! 字样