当前位置:首页 > JSP教程 > JSP常见问题

java tapestry5 布局 参数的处理

复制代码 代码如下:

<?xml version="1.0" encoding="utf-8"?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<head>
<meta name="keywords" content="${ks}">
<meta name="description" content="${desc}">
<title>${title}</title>
</head>
<body >
<t:body/>
</body>

例如如上一个模版页面,在使用时,希望把里边的title,keywords,description动态地更换。
在模版页面的java类里边添加类似如下代码:
复制代码 代码如下:

@parameter(defaultprefix = bindingconstans.literal,name = "title",requred=true)//这里我设为参数必须
@property(write=false)//标注不可写的属性
private string title;

最后在使用时:
复制代码 代码如下:

<div t:type="模版" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" title="这里写你的参数">
xxx
</div>

再重新布置服务器后,已经发现可以显示出正常的标题属性了。。。。
【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐