java JSP应该加什么taglib?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4014848/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JSP what taglib should be added?
提问by Van de Graff
What lines starting with <%@should be added at the beginning of a JSP file to be able to make use of the tag.
应该在 JSP 文件的开头添加哪些以<%@开头的行才能使用标记。
I have added the following line to the beginning of my jsp.
我已将以下行添加到我的 jsp 的开头。
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
But Eclipse IDE says
但是 Eclipse IDE 说
The tag handler class for "html:link" (org.apache.struts.taglib.html.LinkTag) was not foundon the Java Build Path
在 Java 构建路径上找不到“html:link”(org.apache.struts.taglib.html.LinkTag)的标记处理程序类
next to the < html:link> tag.
< html:link> 标签旁边。
What is wrong here?
这里有什么问题?
What I am trying to do is - load page1.jsp from homepage.jspthrough struts actionmapping.
我想要做的是 -通过struts actionmapping从 homepage.jsp 加载 page1.jsp。
回答by Buhake Sindi
If you have download the full struts jar, you don't need to declare your taglibs in web.xml
.
如果您下载了完整的 struts jar,则无需在web.xml
.
- Download Struts from here. In my case, I've downloaded the struts-1.3.10-all.zip
- Copy all the jars from the
<zipped file>\struts-1.3.10\lib
into yourWEB-INF\lib
folder (in your project). - At the top of each JSP page that will use JSP tags, add line(s) declaring the JSP tag libraries used on this particular page, like this:
- 从这里下载 Struts 。就我而言,我已经下载了 struts-1.3.10-all.zip
- 将所有 jars 从 复制
<zipped file>\struts-1.3.10\lib
到您的WEB-INF\lib
文件夹(在您的项目中)。 - 在将使用 JSP 标记的每个 JSP 页面的顶部,添加行声明此特定页面上使用的 JSP 标记库,如下所示:
Example:
例子:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
More on the Struts 1.x installation Guide.
有关Struts 1.x 安装指南的更多信息。
回答by Tomas Narros
You have to declare it at your web.xml
deployment descriptor:
您必须在web.xml
部署描述符中声明它:
<taglib>
<taglib-uri>http://struts.apache.org/tags-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
And keep a copy of the TLD file at the location specified there.
并在此处指定的位置保留 TLD 文件的副本。
Also, you have to check that you have included the struts-taglib.jar
on your classpath (the /WEB-INF/lib folder, in this case).
此外,您必须检查您是否已将 包含struts-taglib.jar
在类路径中(在本例中为 /WEB-INF/lib 文件夹)。