码迷,mamicode.com
首页 > Web开发 > 详细

JSTL基础 SimpleTag 自定义标签 标签体empty

时间:2017-12-06 20:09:14      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:-name   结构   getc   cli   rar   highlight   tle   short   oca   

礼悟:
     好好学习合思考,尊师重道存感恩。叶见寻根三返一,江河湖海同一体。
          虚怀若谷良心主,愿行无悔给最苦。读书锻炼强身心,诚劝且行且珍惜。




       javaEE:7           
       javaSE:1.8
          JSTL:1.2.2  
      server:tomcat 8.5
    browser:Chrome/Firefox
             os:windows7 x64
            ide:MyEclipse 2017

 

项目结构

技术分享图片

 

 
jizuiku-tags.tld

<?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">
  
  <tlib-version>1.0</tlib-version>
  <short-name>jzk</short-name>
  <uri>http://www.jizuiku.com/tags/1.0</uri>
  
  <!-- 配置标签 -->
  <tag>
  	<name>sayHelloWold</name><!-- 指定当前标签的名称 -->
  	<tag-class>com.jizuiku.tag.MyTag</tag-class><!-- 当前标签的处理类 -->
  	<body-content>empty</body-content><!-- 指定标签体的类型 empty空标签 -->
  </tag>
  
</taglib>

 

MyJsp.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="j" uri="/WEB-INF/tlds/jizuiku-tags.tld"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP ‘MyJsp.jsp‘ starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
	<j:sayHelloWold/>
  </body>
</html>

 

浏览器查看

技术分享图片


扩展
  参考链接:https://www.cnblogs.com/shanheyongmu/p/5940945.html

  


学习资源:itcast和itheima视频库。如果您有公开的资源,可以分享给我的话,用您的资源学习也可以。
博文是观看视频后,融入思考写成的。博文好,是老师讲得好。博文坏,是 给最苦 没认真。

JSTL基础 SimpleTag 自定义标签 标签体empty

标签:-name   结构   getc   cli   rar   highlight   tle   short   oca   

原文地址:http://www.cnblogs.com/jizuiku/p/7993927.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!