Java 找不到springframework的标签库描述符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4219166/
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-08-14 14:43:10  来源:igfitidea点击:

Can not find the tag library descriptor of springframework

javaspringjspspring-mvcjsp-tags

提问by JLBarros

I'm trying to follow the example of spring JPetStore but I get an error in the JSP pages in the line that references the lib tag spring:

我正在尝试遵循 spring JPetStore 的示例,但在引用 lib 标记 spring 的行中的 JSP 页面中出现错误:

Can not find the tag library descriptor for "http://www.springframework.org/tags"

找不到“http://www.springframework.org/tags”的标签库描述符

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

What is the URL of this library?

这个库的网址是什么?

Is there any way to avoid the direct dependence on this URL?

有什么办法可以避免直接依赖这个URL吗?

Thanks in advance

提前致谢

采纳答案by Adalarasan Sachithanantham

  1. Download the Spring dependency jar
  2. Place it to the lib folder path is /WEB-INF/lib/spring.jar
  3. Then open the web.xml and the sample code is:

    <taglib>
      <taglib-uri>/WEB-INF/spring.tld</taglib-uri>
      <taglib-location>/WEB-INF/spring.tld</taglib-location>
    </taglib>
    
  4. Then the taglib is indicated where the jar file locates in ur system.

    <%@ taglib prefix="spring" uri="/WEB-INF/spring.tld" %>
    
  1. 下载 Spring 依赖 jar
  2. 把它放到lib文件夹路径是/WEB-INF/lib/spring.jar
  3. 然后打开web.xml,示例代码为:

    <taglib>
      <taglib-uri>/WEB-INF/spring.tld</taglib-uri>
      <taglib-location>/WEB-INF/spring.tld</taglib-location>
    </taglib>
    
  4. 然后taglib被指示jar文件在你的系统中的位置。

    <%@ taglib prefix="spring" uri="/WEB-INF/spring.tld" %>
    

回答by Steven Benitez

The TLD should be located in the spring.jar. Your application won't have any dependency on that URL. It's just used as a unique name to identify the tag library. They could just as well have made the URI "/spring-tags", but using URLs is pretty common place.

TLD 应位于spring.jar. 您的应用程序不会对该 URL 有任何依赖性。它只是用作标识标签库的唯一名称。他们也可以将 URI 设为“/spring-tags”,但使用 URL 是很常见的地方。

回答by ElPasmo

Removing the space between @and taglibdid the trick for me: <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

删除@taglib之间的空格对我来说很有效:<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

回答by stivlo

I know it's an old question, but the tag library http://www.springframework.org/tagsis provided by spring-webmvcpackage. With Maven it can be added to the project with the following lines to be added in the pom.xml

我知道这是一个老问题,但标签库http://www.springframework.org/tags是由spring-webmvcpackage.json提供的。使用 Maven,它可以添加到项目中,并在项目中添加以下几行pom.xml

<properties>
    <spring.version>3.0.6.RELEASE</spring.version>
</properties>

<dependencies>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>

Without Maven, just add that jar to your classpath. In any case it's not necessary to refer the tld file directly, it will be automatically found.

如果没有 Maven,只需将该 jar 添加到您的类路径中。在任何情况下都不需要直接引用 tld 文件,它会自动找到。

回答by Stranger

I finally configured RAD to build my Maven-based project, but was getting the following exception when I navigate to a page that uses the Spring taglib:

我最终配置了 RAD 来构建我的基于 Maven 的项目,但是当我导航到使用 Spring taglib 的页面时遇到以下异常:

JSPG0047E: Unable to locate tag library for uri http://www.springframework.org/tagsat com.ibm.ws.jsp.translator.visitor.tagfiledep.TagFileDependencyVisitor.visitCustomTagStart(TagFileDependencyVisitor.java:76) ...

JSPG0047E: 无法在 com.ibm.ws.jsp.translator.visitor.tagfiledep.TagFileDependencyVisitor.visitCustomTagStart(TagFileDependencyVisitor.java:76)上找到 uri http://www.springframework.org/tags 的标记库 ...

The way I had configured my EAR, all the jars were in the EAR, not in the WAR's WEB-INF/lib. According to the JSP 2.0 spec, I believe tag libs are searched for in all subdirectories of WEB-INF, hence the issue. My solution was to copy the tld files and place under WEB-INF/lib or WEB-INF.. Then it worked.

按照我配置 EAR 的方式,所有 jar 都在 EAR 中,而不是在 WAR 的 WEB-INF/lib 中。根据 JSP 2.0 规范,我相信在 WEB-INF 的所有子目录中搜索标签库,因此存在问题。我的解决方案是复制 tld 文件并将其放在 WEB-INF/lib 或 WEB-INF 下。然后它起作用了。

回答by Rubén Fanjul Estrada

you have to add the dependency for springs mvc

您必须为 springs mvc 添加依赖项

tray adding that in your pom

托盘在你的 pom 中添加

<!-- mvc -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>

回答by Uresh Kuruhuri

Here is another case.

这是另一个案例。

We have several portlets in different portlet application war and all of them use spring. So in order to reduce size of each war, we have created shared libraries for spring jars in the WebSphere Portal server.

我们在不同的 portlet 应用程序War中有几个 portlet,它们都使用 spring。因此,为了减少每次War的规模,我们在 WebSphere Portal 服务器中为 spring jar 创建了共享库。

However, I came across the same issue as above of not having the spring form tags being referred from the jsp files.

但是,我遇到了与上述相同的问题,即没有从 jsp 文件中引用 spring 表单标签。

In order to resolve, I have copied the spring-form.tld file into the WEB-INF/ directory and redeployed the war and it worked.

为了解决,我已经将 spring-form.tld 文件复制到 WEB-INF/ 目录中,并重新部署了 war 并且它起作用了。

Hope it helps for anyone having a similar issue as mine.

希望它对任何与我有类似问题的人有所帮助。

回答by Eduardo Chavira

If you are using maven use this dependency:

如果您使用 Maven,请使用此依赖项:

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-taglibs</artifactId>
    <version>3.1.4.RELEASE</version>
</dependency>

回答by Bamboomy

I had the same issue with weblogic 12c and maven I initially while deploying from eclipse (kepler) (deploying from the console gave no errors).

我最初在从 eclipse (kepler) 部署时遇到了与 weblogic 12c 和 maven 相同的问题(从控制台部署没有错误)。

The other solutions given on this page didn't help.

此页面上给出的其他解决方案没有帮助。

I extracted the spring.tld spring-form.tldfiles of the spring-webmvc jar (which I found in my repository) in the web\WEB-INF folder of my war module;

我在我的 war 模块的 web\WEB-INF 文件夹中提取了spring-webmvc jar(我在我的存储库中找到)的spring.tld spring-form.tld文件;

I did a fresh build; deployed (from eclipse) into weblogic 12c, tested the application and the error was gone;

我做了一个新的构建;部署(从eclipse)到weblogic 12c,测试应用程序,错误消失;

I removed the spring.tld spring-form.tldfiles again and after deleting; rebuilding and redeploying the application the error didn't show up again.

我再次删除了spring.tld spring-form.tld文件,删除后;重建和重新部署应用程序,错误没有再次出现。

I double checked whether the files were gone in the war and they were indeed not present.

我仔细检查了这些文件是否在War中消失了,它们确实不存在。

hope this helps others with a similar issue...

希望这可以帮助其他有类似问题的人......

回答by Xelian

If you want direct link:

如果你想要直接链接:

https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/resources/META-INF/spring-form.tld

https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/resources/META-INF/spring-form.tld

Or from repos:

或从回购:

JCenter: link

JCenter链接

Maven Central: link

Maven 中心链接

And if you need as Gradle dependency:

如果您需要 Gradle 依赖项:

compile 'org.springframework:spring-webmvc:4.1.6.RELEASE

编译'org.springframework:spring-webmvc:4.1.6.RELEASE

More information about spring-form: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/spring-form.tld.html

有关弹簧形式的更多信息:http: //docs.spring.io/spring/docs/current/spring-framework-reference/html/spring-form.tld.html