您现在的位置:主页 > 技术中心 > WEB编程 > JSP

JSP技术中的开发自定义标签(2)

来源:未知 责任编辑:责任编辑 发表时间:2014-01-20 07:53 点击:

              JspWriter out = this.pageContext.getOut();
             
              String ip = request.getRemoteAddr();
              try {
                     out.print(ip);
              } catch (IOException e) {
                     throw new RuntimeException(e);
              }
             
             
              return super.doStartTag();
       }
}
 
 
2.在tld文件里面对标签处理器类进行描述,tld文件的位置在web-inf下面可以在tomcat的webapps下面抄一下
 
 
 
<?xml version="1.0" encoding="UTF-8" ?> 
 
<taglib 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 http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" 
    version="2.0"> 
    <description>A tag library exercising SimpleTag handlers.</description> 
    <tlib-version>1.0</tlib-version> 
    <short-name>Bird</short-name> 
    <uri>http://www.bird.net</uri>  
    <tag> 
        <name>viewIP</name> 
        <tag-class>com.bird.web.tag.ViewIPTag</tag-class> 
        <body-content>empty</body-content> 
    </tag> 
    </taglib> 
<?xml version="1.0" encoding="UTF-8" ?>
 
<taglib 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 http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
    version="2.0">
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片

推荐热点

  • JSP与Servlet
  • 自己动手写MiniBBS系列(基本篇)之用户登录
  • JSP取当前日期
  • JDBC 入门(一)
  • 打开一个jsp页面默认查询所有数据,调用action
  • 使用JSP标签库验证用户的输入(2)完
  • 自定义JSP标签(tag)浅议
  • WIN98/2000下的jsp服务器
  • JSP内建对象(二)
?? - ?? - ÝřŝžľŘÝź - TAGąęÇŠ - RSSśŠÔÄ - ??
Copyright © 2004-2024 上海卓卓网络科技有限公司