|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
C#是盗用了Java的源代码,仿照开发的,原因是Java是开源的啊,盗了也白盗,还有一点,开发C#语言的团队是就是开发Java语言的团队,是微软重金挖过去的啊
1.app.tld
<?xmlversion="1.0"encoding="UTF-8"?>
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.1</jsp-version>
<tag>
<name>display</name>
<tagclass>com.test.DisplayTag</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>page</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
</taglib>
2.DisplayTag.java
packagecom.test;
importjava.util.List;
importjavax.servlet.http.HttpSession;
importjavax.servlet.jsp.JspException;
importjavax.servlet.jsp.JspTagException;
importjavax.servlet.jsp.JspWriter;
importjavax.servlet.jsp.tagext.TagSupport;
importcom.test.Hibernate.User;
publicclassDisplayTagextendsTagSupport{
/**
*
*/
privatestaticfinallongserialVersionUID=1L;
privateStringname="alluser";
privateStringpage;
publicStringgetName(){
returnname;
}
publicvoidsetName(Stringname){
this.name=name;
}
publicStringgetPage(){
returnpage;
}
publicvoidsetPage(Stringpage){
this.page=page;
}
privateStringtest;
publicStringgetTest(){
returntest;
}
publicvoidsetTest(Stringtest){
this.test=test;
}
@Override
publicintdoStartTag()throwsJspException{
returnSKIP_BODY;
}
publicintdoEndTag()throwsJspException{
booleanvalid=false;
HttpSessionsession=pageContext.getSession();
if(session!=null&&session.getAttribute(name)!=null){
valid=true;
}else{
try{
pageContext.forward(page);
}catch(Exceptione){
//TODO:handleexception
thrownewJspException(e.toString());
}
}
JspWriterout=pageContext.getOut();
try{
Listusers=(List)session.getAttribute("alluser");
if(valid){
out.println("<tableborder="2"width=100%height=100%>");
out.println("<tr>");
out.println("<th>ID</th>");
out.println("<th>Name</th>");
out.println("<th>password</th>");
out.println("</tr>");
for(inti=0;i<users.size();i++){
Useruser=(User)users.get(i);
out.println("<tr>");
out.println("<td>"+user.getId()+"</td>");
out.println("<td>"+user.getUsername()+"</td>");
out.println("<td>"+user.getPassword()+"</td>");
}
out.println("</table>");
}else{
out.println("null");
}
}catch(Exceptione){
//TODOAuto-generatedcatchblock
thrownewJspTagException("IOException:"+e.toString());
}
returnSKIP_PAGE;
}
@Override
publicvoidrelease(){
//TODOAuto-generatedmethodstub
super.release();
this.name="alluser";
this.page="login.jsp";
}
}
<p>
java主要分三块,j2se:java的基础核心语言。j2me:java的微型模块,专门针对内存小,没有持续电源等小型设备。j2ee:java的企业模块,专门针对企业数据库服务器的连接维护。 |
|