Error using JSTL XML taglib - attribute xml does not accept any expressions

杀马特。学长 韩版系。学妹 提交于 2019-12-02 04:28:17

Your code is picking up an "incorrect" version of x-1_0.tld, probably due to classpath issues. I see for instance on my current classpath, I have one version of x-1_0.tld that ALLOWS runtime-expressions ${syntax} in this tag and one that does not. The one in standard.jar does not allow EL expressions, while the one I have in jetty does.

I found that the Sun documentation refers to the URI as

http://java.sun.com/jsp/jstl/xml

The tag is now being called correctly, so this was the cause of the problem; however I am getting a NullPointerException in doEndTag()... ho hum

Not exactly, you should use

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

to use JSTL 1.1.

Unfortunately the standard.jar files includes many versions of *.tld tag for eg.

  • c-1_0-rt.tld
  • c-1_0.tld
  • c.tld
  • fmt-1_0-rt.tld
  • fmt-1_0.tld
  • fmt.tld
  • fn.tld
  • permittedTaglibs.tld
  • scriptfree.tld
  • sql-1_0-rt.tld
  • sql-1_0.tld
  • sql.tld
  • x-1_0-rt.tld
  • x-1_0.tld
  • x.tld

so by using

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

you tell the jsp to specifically use JSTL 1.1 which btw fixes the above issue, if this does not work try using

<%@ page isELIgnored="false" %>

which basically tells jsp to evaluate EL.

/srm

Mansi Singhal

Use the following code:

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

Instead of:

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

I realize this question was asked quite a while ago but I just ran into the same problem. In my case, the example I was following directed me to use:

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

When I should have been using:

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

I was staring at the solution for a while before the extra jsp in the uri popped out at me.

change <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> is not right for me. for my project(web-app version="3.0" ) IDE(MyEclipse) I see the configuration file of x.tld.There is the false of select which do not allow the select apperance ${} or <%=%>.So I got a way to cheat in the web.xml.

  1. <jsp-config> <taglib> <taglib-uri>/huang</taglib-uri> <taglib-location>/WEB-INF/x.tld</taglib-location> </taglib> </jsp-config> add to web.xml

  2. declare the new taglib-url name "huang" to my jsp file like this:

    <%@ taglib prefix="x" uri="/huang" %>

  3. to use<x:out select="$casexml//案例//${node.name }" />

    I can get the right result

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!