| public String getDist() { return dist; }
public void setDist(String dist) { this.dist = dist; }
public String getDistName() { return distName; }
public void setDistName(String distName) { this.distName = distName; }
public String getScope() { return scope; }
public void setScope(String scope) { this.scope = scope; }
public String getSource() { return source; }
public void setSource(String source) { this.source = source; } } | 标签的tld也一起给出吧,虽然不是要害
代码:
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0" 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 web-jsptaglibrary_2_0.xsd">
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>J2J</shortname>
<uri>/J2J</uri>
<tag>
<name>newObject</name>
<tagclass>net.vlinux.tag.j2j.NewObject</tagclass>
<bodycontent>JSP</bodycontent>
<info></info>
<attribute>
<name>distName</name>
<required>true</required>
</attribute>
<attribute>
<name>dist</name>
<required>true</required>
</attribute>
<attribute>
<name>scope</name>
<required>true</required>
</attribute>
<attribute>
<name>source</name>
<required>true</required>
</attribute>
</tag>
</taglib> |
具体调用的JSP页面
代码
<%@ taglib uri="/WEB-INF/J2J.tld" prefix="jj"%>
<%
//创建一个简单对象
net.vlinux.test.User user = new net.vlinux.test.User();
user.setId(new Integer(1));
user.setName("vlinux");
user.setPassword("lovefs");
user.setUsername("oldmanpushcart");
//把对象放到request中去
request.setAttribute("user",user);
%>
<!--
这里要注重
dist是目标Javascript对象,这个是必须和web设计人员事先约定好的
distName 是目标Javascript对象实例的名,这个也是必须和web设计人月事先约定好
scope 告诉标签去那个范围寻找java对象的实例
source 源对象,也就是java对象,标签会通过scope确定的范围搜寻source
-->
<jj:newObject dist="User" distName="user" scope="request" source="user"/>
|
| 共3页: 上一页 [1] 2 [3] 下一页 |
评论加载中…