真正调通Tabestry5的最简单tutorial程序!

    上网查了下Tabestry5的文档,大多都是把官网的文档拿来翻译,并没有做调式,这种不负责任的态度,很容易误导别人,这种文章不是帮人,而是害人,特别是经验不是丰富的兄弟姐妹。举个简单的例子,web.xml里面配置各filter,居然还是这样:

    <filter>
        <filter-name>app</filter-name>
        <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
    </filter>

    实在搞不懂,这个最简单的问题也容易忽视。正确的是:

    <filter>
        <filter-name>app</filter-name>
        <filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
    </filter>

 

    ok, 切入正题,下面我将详细的说下这个tutorial.

 

1. 环境

      JDK: 1.6

      TOMCAT:6.0以上,我的是6.0.26

      tapestry:5.1.0.5,应该5.1以上都类似。

      OS:32位WindowsXP Home edition.

      IDE:eclipse 3.5(可选),我直接在tomcat安装目录下做的。

 

2. 建立目录结构

    tabdemo

          WEB-INF

                  classes

                  lib

                  web.xml

          index.tml        

 

3.源文件

1)Index.java

package demo.pages;

import java.util.Date;
public class Index
{
        public Date getCurrentTime()
        {
                return new Date();
        }
}

 

2)index.tml

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">
    <head>
        <title>tutorial1 Start Page</title>
    </head>
    <body>
        <h1>tutorial1 Start Page</h1>

        <p> This is the start page for this application, a good place to start your modifications.
            Just to prove this is live: </p>

        <p> The current time is: ${currentTime}. </p>


        <p>
            [<t:pagelink t:page="Index">refresh</t:pagelink>]
        </p>
    </body>
</html>

 

3) web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   version="2.5">
    <display-name>app Tapestry 5 Application</display-name>
    <context-param>
        <!-- The only significant configuration for Tapestry 5, this informs Tapestry
of where to look for pages, components and mixins. -->
        <param-name>tapestry.app-package</param-name>
        <param-value>demo</param-value>
    </context-param>
   
    <context-param>
    <param-name>tapestry.production-mode</param-name>
    <param-value>false</param-value>
  </context-param>

    <filter>
        <filter-name>app</filter-name>
        <filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>app</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

 

4.所需要的lib库

 

lib库

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值