创建自己的taglib 并打包入jar
1. Create a TLD (tag library descriptor) file namedmy-tags.tld. For
more information, see Creating
a Tag Library Descriptor.
例如:
<taglib>
<display-name>Raptor JSP Taglib</display-name>
<tlib-version>1.0</tlib-version>
<jspversion>2.0</jspversion>
<short-name>r</short-name>
<uri>http://ebay.com/raptor</uri>
<tag>
<name>deferredFragment</name>
<tagclass>com.ebay.raptor.fragment.jsp.DeferredFragmentTag</tagclass>
<body-content>scriptless</body-content>
<!--dynamic-attributes>true</dynamic-attributes-->
<attribute>
<name>afterRender</name>
<type>String</type>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>beforeRender</name>
<type>String</type>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>dependency</name>
<type>Object</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>fragmentDependencies</name>
<type>String</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>delay</name>
<type>int</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>timeoutFragment</name>
<type>String</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>timeoutURL</name>
<type>String</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>id</name>
<type>String</type>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>inline</name>
<type>boolean</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>outerElement</name>
<type>String</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>style</name>
<type>String</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>styleClass</name>
<type>String</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
2. Create a directory containing the compiled Java tag handler class files used in your tag library.
3. Create
a sub-directory of the directory you created in step 2 and call it META-INF.
注意my-tag.tld必须放在META-INF里,这也是web container回去search tld文件的位置
4. Copy the my-tags.tld file
you created in step
1 into the META-INF directory
you created in step
3
5. Archive your compiled Java class files into a jar file
6.Copy the jar file
into the WEB-INF/lib directory of the Web application that uses your tag library.
有些文档说需要在web.xml 中提供对tag library 的引用才可以在JSP中使用,如下:
<taglib>
<taglib-uri>myjar.tld</taglib-uri>
<taglib-location>
/WEB-INF/lib/myTagLibrary.jar
</taglib-location>
</taglib>
但实际情况是,至少在Tomcat 和 Geronimo 服务器中,不需要上面的配置,服务器可以自己找到Jar里的tld文件,可能不同的服务器其实现不一样吧。
7.Reference the tag library
in your JSP. For example:
<%@ taglib prefix="r" uri="http://ebay.com/raptor"%>
<r:includeRaptorJS />
参考:
http://docs.oracle.com/cd/E15051_01/wls/docs103/taglib/admin.html#wp364493
http://www.ibm.com/developerworks/cn/java/j-jsp07233/index.html
版权声明:本文为博主原创文章,未经博主允许不得转载。
创建自己的taglib 并打包入jar的更多相关文章
- maven创建的quickstart项目生成可执行jar
maven创建的quickstart项目在打包成jar后,通过Java -jar 文件名.jar 会提示没有主清单属性. 为了生成可执行的jar,需要添加maven插件 maven-shade-plu ...
- (3)Maven快速入门_3在Eclipse中创建Maven项目打包成jar
Eclipse中创建Maven项目 new ---> maven project ----> next 如下 普通java项目 选择 如下 quickstart 创建项目 : 输入 G ...
- [Java] Java 打包成jar包 和 解压jar包
解压jar包 jar xf xxx.jar 打包成jar包 方法一:通过jar命令 jar命令的用法: 下面是jar命令的帮助说明: 用法:jar {ctxui}[vfm0Me] [jar-file] ...
- Java程序打包成jar包
方法一:通过jar命令 jar命令的用法: 下面是jar命令的帮助说明: 用法:jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] ...
- java打包成jar文件
JAR包是Java中所特有一种压缩文档,其实大家就可以把它理解为.zip包.当然也是有区别的,JAR包中有一个META-INF\MANIFEST.MF文件,当你找成JAR包时,它会自动生成.JAR包是 ...
- windows10计划任务启动bat执行jar打包的jar文件
今天公司要用bat文件执行jar打包的java文件,运行没项目的程序,并且用任务计划开机自启,今天记录下坑 系统:win10 一.编写.bat执行用jar打包的jar文件 @echo off java ...
- 在JAR中打包使用JAR库
不知大家在写Java程序的时候有没有这种需求: 将引用其他第三方JAR库的项目打包成一个JAR文件执行.也就是说在你打包好的JAR文件里再包括那些你引用的第三方JAR文件,合成一个JAR包,这样仅仅需 ...
- java代码打包成jar以及转换为exe
教你如何把java代码打包成jar文件以及转换为exe可执行文件 1.背景: 学习java时,教材中关于如题问题,只有一小节说明,而且要自己写麻烦的配置文件,最终结果却只能转换为jar文件.实在是心有 ...
- 手把手教你如何把java代码,打包成jar文件以及转换为exe可执行文件
1.背景: 学习java时,教材中关于如题问题,只有一小节说明,而且要自己写麻烦的配置文件,最终结果却只能转换为jar文件.实在是心有不爽.此篇博客教你如何方便快捷地把java代码,打包成jar文件以 ...
随机推荐
- Python之访问set
dict的作用是建立一组 key 和一组 value 的映射关系,dict的key是不能重复的. 有的时候,我们只想要 dict 的 key,不关心 key 对应的 value,目的就是保证这个集合的 ...
- [LeetCode] Climbing Stairs 斐波那契数列
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb ...
- 关于Struts2中param的作用
1.页面传参与配置传参的区别: 如果页面Form表单的参数在Action类中有相应的setter方法,则会优先取页面Form表单传过来的值,如果页面没有该属性同名的参数,则会从配置文件中取同名的参数值 ...
- Linux signal 那些事儿(4)信号的deliver顺序【转】
转自:http://blog.chinaunix.net/uid-24774106-id-4084864.html 上一篇博文提到了,如果同时有多个不同的信号处于挂起状态,kernel如何选择deli ...
- nfc是什么?nfc功能是什么?
http://android.tgbus.com/lab/software/201208/447420.shtml nfc是什么?nfc功能是什么?出现在我们手机上的nfc功能怎么用?下面请看今天小编 ...
- c++语言虚函数实现多态的原理(更新版)
自上一个帖子之间跳过了一篇总结性的帖子,之后再发,今天主要研究了c++语言当中虚函数对多态的实现,感叹于c++设计者的精妙绝伦 c++中虚函数表的作用主要是实现了多态的机制.首先先解释一下多态的概念, ...
- [CF665F]Four Divisors
题目大意: 给定$n(n\leq10^{11})$,求$\displaystyle\sum_{i=1}^n[\tau(i)=4]$. 思路: 设$p,q$为不相等的质数,则满足$\tau(i)=4$的 ...
- python中mp3转wav(Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work")
1.下载pydub:pip install pydub 2.下载与操作系统一致的ffmpeg:http://ffmpeg.org/download.html 3.解压后将下载的ffmpeg下的bin目 ...
- 初探ggplot2 geom__制作面积图
大家大概都对如下信息图并不陌生,该图用100%堆积面积图的方式来表现不同时期不同国家人数所占的比例.这是一种很有意思的表达方式,而面积图也是很常用的数据图表,现在让我们一起来看看如何在R里用g ...
- 转:GEF 英文全称Graphical Editor Framework
http://blog.csdn.net/chancein007/article/category/2713827