这就是重点:我想使用这个模板(示例)为我的Web应用程序的所有数据网格创建一个布局,如果不是你想要做什么?:(是必要的动态)
Layout.java
class Layout {
public abstract String buttons();
public abstract String data();
public String print()
{
String layoutOutput = "<div class=\"buttons\">";
layoutOutput = layoutOutput + this.buttons();
layoutOutput = layoutOutput + "</div>";
layoutOutput = "<div class=\"data\">";
layoutOutput = layoutOutput + this.data();
layoutOutput = layoutOutput + "</div>";
return layoutOutput;
}
}
MyList.java
class MyList extends Layout {
public String buttons()
{
return "<button>One</button><button>Two</button>";
}
public String data()
{
return "<table>...</table>";
}
}
MyJSP.jsp
<%
MyList l = new MyList();
response.write( l.print() );
%>