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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 04:23:18  来源:igfitidea点击:

JSP what taglib should be added?

javajspstruts

提问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.

  1. Download Struts from here. In my case, I've downloaded the struts-1.3.10-all.zip
  2. Copy all the jars from the <zipped file>\struts-1.3.10\libinto your WEB-INF\libfolder (in your project).
  3. 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:
  1. 这里下载 Struts 。就我而言,我已经下载了 struts-1.3.10-all.zip
  2. 将所有 jars 从 复制<zipped file>\struts-1.3.10\lib到您的WEB-INF\lib文件夹(在您的项目中)。
  3. 在将使用 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.xmldeployment 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.jaron your classpath (the /WEB-INF/lib folder, in this case).

此外,您必须检查您是否已将 包含struts-taglib.jar在类路径中(在本例中为 /WEB-INF/lib 文件夹)。