jsp中自定义Taglib详解(4)

<jsp-config> <taglib> <taglib-uri>firstTag</taglib-uri> <taglib-location>/WEB-INF/tag.tld</taglib-location> </taglib> </jsp-config> 在jsp文件中使用标签:tag.jsp <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ taglib uri="firstTag" prefix="my"%> <jsp:useBean scope="request"> <jsp:setProperty property="name" value="Hackiller"/> <jsp:setProperty property="password" value="123"/> </jsp:useBean> <jsp:useBean scope="request"> <jsp:setProperty property="name" value="YangYang"/> <jsp:setProperty property="password" value="456"/> </jsp:useBean> <% List list = new ArrayList(); list.add(userVo1); list.add(userVo2); pageContext.setAttribute("voList",list); %> <html> <head> <title>My JSP 'tag.jsp' starting page</title> </head> <body> <h2>This is my JSP page:测试taglib.</h2> <hr> <h2>自定义迭代标签:</h2> <table> <tr><td>姓名</td><td>密码</td></tr> <my:forEach collection="voList"> <tr> <td><my:getProperty property="name"/></td> <td><my:getProperty property="password"/></td> </tr> </my:forEach> </table> <hr> <h2>表达式调用类的静态方法:</h2> 2+5=${my:add(2,5)} </body> </html>

以上就是小编为大家带来的jsp中自定义Taglib详解全部内容了,希望大家多多支持脚本之家~

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzjpwf.html