JSPX名称空间对EL函数不可见吗? [英] JSPX namespaces not visible for EL functions?

查看:91
本文介绍了JSPX名称空间对EL函数不可见吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JSPX(用于JSP的纯XML语法),并且遇到了看起来应该可以使用的方法,但是没有用.我要在jsp:root元素中使用名称空间声明导入taglib,然后在以后的元素和EL函数中使用它们:

<jsp:root version="2.0"
    xmlns:jsp="http://java.sun.com/JSP/
    xmlns:c="urn:jsptld:/WEB-INF/tld/c.tld"
    xmlns:fn="urn:jsptld:/WEB-INF/tld/fn.tld">
    ...
    <c:if test="${fn:length(list) &gt; 0">
        ...
    </c:if>
    ...
</jsp:root>

我遇到一个异常,说属性前缀fn不对应于任何导入的标记库".其他页面工作正常,但是此页面的不同之处在于它使用了标记库中包含的一些EL函数.

我是否需要其他类型的导入,以将这些taglib前缀带入对EL函数调用可见的作用域?

解决方案

为什么不使用完整的TLD URI?您可以在此处中找到有效JSTL TLD的概述URI(单击您感兴趣的任何JSTL taglib以获得有效的声明示例).

请确保:您已将JSTL JAR文件(jstl.jar和/或standard.jar,具体取决于JSTL版本)放置在类路径中,直到1.1都存在,而在1.2中则只有jstl.jar)而您不是提取它们,也没有像一些可怜的在线教程所说的那样,用松散的文件和声明使类路径和/或web.xml混乱?

I'm attempting to use JSPX (pure XML syntax for JSP) and running into what seems like it should work, but doesn't. I'm importing taglibs using namespace declarations in the jsp:root element, then using these later on for elements as well as EL functions:

<jsp:root version="2.0"
    xmlns:jsp="http://java.sun.com/JSP/
    xmlns:c="urn:jsptld:/WEB-INF/tld/c.tld"
    xmlns:fn="urn:jsptld:/WEB-INF/tld/fn.tld">
    ...
    <c:if test="${fn:length(list) &gt; 0">
        ...
    </c:if>
    ...
</jsp:root>

I get an exception saying "The attribute prefix fn does not correspond to any imported tag library". Other pages work fine, but this page differs in that it uses a few EL functions contained in a tag library.

Is there a different kind of import I need that will bring these taglib prefixes into a scope that's visible for EL function calls?

解决方案

Why don't you use the full TLD URI? You can find here an overview of the valid JSTL TLD URI's (click at any JSTL taglib of your interest to get the valid declaration examples).

To be sure: you have placed the JSTL JAR file(s) (jstl.jar and/or standard.jar, depending on JSTL version, until with 1.1 it's both and in 1.2 it's only jstl.jar) in the classpath and you did not extract them nor cluttered the classpath and/or web.xml with loose files and declarations as some poor online tutorials say?

这篇关于JSPX名称空间对EL函数不可见吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆