java自定义 注解 annotation、标签库tag、监听listener、junit简单测试代码(五)

2014-11-24 02:08:42 · 作者: · 浏览: 4
ent=bodyContent; } }
web.xml

  

  
 
 
   
	
    
     
     
      /demotag
      
     
      /WEB-INF/tagTest.tld
      
     
     
     
      /hello/rui
      
     
      /WEB-INF/myTag.tld
      
     
     
     
      /bodyTag/rui
      
     
      /WEB-INF/bodyTag.tld
      
     
     
     
      /itertor/rui
      
     
      /WEB-INF/itertor.tld
      
     
     
     
      /simple/rui
      
     
      /WEB-INF/simple.tld
      
     
   

	
   
	
    
    
     org.rui.listener.ListTest
     
   
	
	
   
	
    
    
     org.rui.listener.SessionListener
     
   
	
	
    
    
     org.rui.listener.ReplyListener
     
   
	
	

 
    
    
     index.jsp
     
   
 
 

  

tld =================

  




  
 
   
    1.0
   
 
   
    1.2
   
 
   
    bodyTagExamples
   
 
   
    /bodyTag/rui
   
 
  
    
    
     bodyTagTest
     
    
     org.rui.tag.BodyTagExample
     
    
     jsp
     
     
     
      counts
      
     
      true
      
     
      true
      
     
   
 

  

  


  

  
   
    1.0
   
  
   
    examples
   
  
   
    /demotag
   

 
    
    
     hello_int
     
    
     org.rui.tag.HelloTag_Interface
     
    
     empty
     
   

 


  

  


  
 
   
    1.0
   
 
   
    1.2
   
 
   
    simpleExample
   
 
   
    /simple/rui
   
 
   
    
    
     helloWorld
     
    
     org.rui.tag.HelloWorldSimpleTag
     
    
     empty
     
   
 

  

  


  
    
    
   
    1.0
   
 
   
    
  
    
    
     hello
     
    
     org.rui.tag.TagExample
     
   
  

  

jsp=====

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/demotag" prefix="hello"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<html>
  
    
    My JSP 'demo.jsp' starting page
  
  
  
    

以下是自定义tag显示的内容:


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="/bodyTag/rui" prefix="bt" %>




  
Insert title here


  
 

以下是自定义tag显示的内容:

现在的时间是:<%= new java.util.Date()%>


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/hello/rui" prefix="he"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>



  
    
    
    My JSP 'bodyTag.jsp' starting page
  
  
  

自定义标签 extends TagSupport实现


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="/simple/rui" prefix="sim" %>
    




  
Insert title here



simple Tag 输出测试


======================

太多了,请下载项目源码吧,里面有相关教程文档,免费下载