自定义标签库函数

阅读更多

写Zhangfei.java类

package com.zfei;

public class Zhangfei {
private String name;
public String getName(){
   return this.name;
}
public void setName(String name){
   this.name=name;
}
public static String helloName(String name){
   return "Hello,"+name+"!";
}
}

写TLD文件配置:


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">

一个自定义标签库

0.9

my

http://blog.csdn.com/zfei/tags




具有对集合元素进行循环现实的标签

zf

com.zfei.Zhangfei

JSP


    
     name
    
     true
       
     true




helloName

com.zfei.Zhangfei


   java.lang.String helloName(java.lang.String)


配置web.xml



   http://blog.csdn.com/zfei/tags
   /WEB-INF/mytag.tld

 

JSP测试页面:

<%@ page language="java" contentType="text/html; charset=gb2312"%>
<%@ taglib prefix="my" uri="http://blog.csdn.com/zfei/tags" %>




Insert title here

${my:helloName("zhangfei") }

 

你可能感兴趣的:(jsp标签)