在下载的displaytag-1.1-bin包中有一个最简单的实例全码:
<% request.setAttribute( "test", new TestList(10, false) ); %>
<display:table name="test" />其中test是什么,而TestList又是哪里来的?怎么加了这两句就可以显示出如下的这么多数据:
478.0 Army Lorem sadipscing sanctus et 4 Neapolis
937.0 Lorem est est takimata Roma
966.0 Gladiators eos elitr erat nonumy 9 Olympia
323.0 Taxes tempor sadipscing rebum et 3 Roma
405.0 sed sanctus elitr est Olympia
745.0 invidunt dolores amet clita 0 Roma 实 在搞不明白这些数据是从哪里来的。
<% request.setAttribute( "test", new TestList(10, false) ); %>
<display:table name="test" />其中test是什么,而TestList又是哪里来的?怎么加了这两句就可以显示出如下的这么多数据:
478.0 Army Lorem sadipscing sanctus et 4 Neapolis
937.0 Lorem est est takimata Roma
966.0 Gladiators eos elitr erat nonumy 9 Olympia
323.0 Taxes tempor sadipscing rebum et 3 Roma
405.0 sed sanctus elitr est Olympia
745.0 invidunt dolores amet clita 0 Roma 实 在搞不明白这些数据是从哪里来的。
test是一个标识,对应的就是TestList的对象,
public class Test {
private String name = "";
private String age = "";
/**
* @return
*/
public String getAge() {
return age;
} /**
* @return
*/
public String getName() {
return name;
} /**
* @param string
*/
public void setAge(String string) {
age = string;
} /**
* @param string
*/
public void setName(String string) {
name = string;
}}
再写一个jsp:
<head>
...
<%@ page
import="temp.*"
import="java.util.*"
%>
...
</head><BODY><%
Test test1 = new Test();
test1.setName("name1");
test1.setAge("20");
Test test2 = new Test();
test2.setName("name2");
test2.setAge("22");
Test test3 = new Test();
test3.setName("name3");
test3.setAge("30");
List list = new ArrayList();
list.add(test1);
list.add(test2);
list.add(test3);
%><%
request.setAttribute("test", list);
%><display:table name="test"></display:table></BODY>
public class TestList extends ArrayList{
public TestTable(int n){
Object s=null;
for(int i=0;i<n;i++){
s=new Object();
this.add(s);
}
}
}
test1.setName("name1");
test1.setAge("20");
Test test2 = new Test();
test2.setName("name2");
test2.setAge("22");
Test test3 = new Test();
test3.setName("name3");
test3.setAge("30");
List list = new ArrayList();
list.add(test1);
list.add(test2);
list.add(test3);
写到一个类中?如果写到一个类中要如何与JSP一起调用呢?