您的位置:首页 > Web前端 > JavaScript

小峰servlet/jsp(5)jsp自定义标签

2017-03-05 16:44 253 查看
一、自定义标签helloworld:

二、自定义有属性的标签:

HelloWorldTag.java:继承TagSupport:

1 <%@ page language="java" contentType="text/html; charset=UTF-8"
2     pageEncoding="UTF-8"%>
3 <%@ page import="java.util.*" %>
4 <%@ taglib prefix="java1234" uri="/WEB-INF/java1234.tld" %>
5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
6 <html>
7 <head>
8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9 <title>Insert title here</title>
10 <%
11     List people=new ArrayList();
12     people.add("王二小2");
13     people.add("丝丝光2");
14     people.add("草泥马2");
15     pageContext.setAttribute("people", people);
16 %>
17 </head>
18 <body>
19 <java1234:iterate2 items="people" var="p">
20     <h2>${p }</h2>
21 </java1234:iterate2>
22 </body>
23 </html>


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: