---
title: "struts2标签库struts-tags.tld的使用"
author: "allen2010"
date: "2011-01-04T10:42:00Z"
tags: []
slug: "struts2-struts-tags-tld"
draft: false
lastmod: "2011-01-04T10:42:00Z"
id: 953592
url: "https://allen2010.iteye.com/blog/953592"
---

工程中使用struts2标签

　　一、 struts2标签定义文件在struts2-core-2.0.11.1META-INF 下面,文件名为struts-tags.tld

　　二、 如果工程使用了servlet2.3规范,要做两件事,就能在工程中使用struts2标签了

　　1: 在web.xml中增加标签库的定义

&lt;taglib&gt;  
　　　&lt;taglib-uri&gt;/struts-tags&lt;/taglib-uri&gt;  
　　　&lt;taglib-location&gt;/WEB-INF/lib/struts2-core-2.0.11.1.jar&lt;/taglib-location&gt;  
　　&lt;/taglib&gt;  
/struts-tags 是struts2标签库默认的URI,建议使用这个名称

　　2 在JSP中使用taglib编译指令导入标签库 &lt;%@ taglib prefix="s" uri="/struts-tags" %&gt;

　　三、 如果使用servlet2.4规范,不须要在web.xml中增加标签库定义,只要做一件事,就行

　　1 在JSP中使用taglib编译指令导入标签库 &lt;%@ taglib prefix="s" uri="/struts-tags" %&gt;

　　四、 struts2标签自动提示功能(解决struts2标签出现红叉)

　　1　 把struts2包中的struts-tags.tld提取出来,放入本地硬盘上,我放入了E:workspacepicbinWEB-INFtldstruts-tags.tld

　　2　eclipse--window--preferences 输入TLD进行搜索　，选择Amateras--TLD开始添加本地TLD文件，

　　点Add ,URI 项输入:/struts-tags ,Local Path项输入:E:workspacepicbinWEB-INFtldstruts-tags.tld

　　点OK　 ,重启eclipse 写struts2标签时,就有提示了,红叉也没了

![](http://hi.csdn.net/attachment/201101/4/0_12941089619Pr8.gif)　在