Java JSTL taglib URI 已过时?

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

JSTL taglib URI is obsolete?

javajstl

提问by victor hugo

I've been checking out Spring MVC tutorial and copied this small JSP code from there:

我一直在查看 Spring MVC 教程并从那里复制了这个小的 JSP 代码:

<%@ page session="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
    <head><title>Training, Inc.</title></head>
    <body>
        <h2><c:out value="${message}" /></h2>
    </body>
</html>

There is a string set for message and the c:out tag just prints literally

为消息设置了一个字符串,而 c:out 标签只是按字面打印

${message}

${消息}

I was hitting my head for a while until I remembered an issue I had before and changed the taglib URI to:

我想了一会儿,直到我想起了我之前遇到的一个问题并将 taglib URI 更改为:

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

This solved my little problem

这解决了我的小问题

Some time ago I had a similar issue with XSLT transforming but in that case I had to change from http://java.sun.com/jstl/xmlto http://java.sun.com/jsp/jstl/xml

前段时间我在 XSLT 转换方面遇到了类似的问题,但在这种情况下,我不得不从http://java.sun.com/jstl/xml更改为http://java.sun.com/jsp/jstl/xml

According with this linkmy spring example should've worked just as I pasted from spring tutorial

根据此链接,我的 spring 示例应该可以像我从 spring 教程中粘贴的那样工作

The question is: Any of you guys know where is all this taglib URI confusion documented? Why in the some cases I got the last version from http://java.sun.com/jsp/jstland in other ones I got the last version from http://java.sun.com/jstl

问题是:你们中有人知道所有这些 taglib URI 混淆记录在哪里吗?为什么在某些情况下,我从拿到了最后一个版本http://java.sun.com/jsp/jstl和其他的我从拿到了最后的版本http://java.sun.com/jstl

回答by duffymo

Yes, it's well known that the URI for taglibs changed between JSTL versions 1.0 and 1.1. If you happen to get examples that use the old standard and try to use them with the new taglib JAR you'll have this problem.

是的,众所周知,标记库的 URI 在 JSTL 版本 1.0 和 1.1 之间发生了变化。如果您碰巧得到使用旧标准的示例并尝试将它们与新的 taglib JAR 一起使用,您就会遇到这个问题。

回答by Egwor

If you're still getting this error, but you're hand crafting your pom, you probably have missed the standard library. e.g. I'd missed

如果您仍然收到此错误,但您正在手工制作 pom,则您可能错过了标准库。例如我错过了

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>${jstl.version}</version>
    </dependency>