How do you use JSTL?

我怕爱的太早我们不能终老 提交于 2019-12-18 07:40:31

问题


Trying to use JSTL but have the following problem:

Index.xhtml page:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ice="http://www.icesoft.com/icefaces/component" xmlns:jsp="http://java.sun.com/JSP/Page">
<body>
<c:out value="Hello world!"/>
</body></html>

POM:

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

OUTPUT SOURCE:

        <html id="document:html" lang="en" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" xmlns:jsp="http://java.sun.com/JSP/Page"><head><meta content="Rendered by ICEFaces D2D" name="icefaces" />
.....
    <c:out value="Hello world!"></c:out>
....</body></html>

As you can see its not processing the c:out but just printing it out as text.


回答1:


Seems that:

The solution is to remove the /jsp from the jstl namespace:

xmlns:c="http://java.sun.com/jstl/core"

See this post.




回答2:


I could solve the problem with adding xmlns:fmt="http://java.sun.com/jsp/jstl/fmt" in my xhtml file.

OR

declaring this in my web.xml, and copying the c.tld in /WEB-INF/jsp from my application:

<jsp-config> 
        <taglib> 
               <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri> 
               <taglib-location>/WEB-INF/jsp/c.tld</taglib-location> 
        </taglib> 
</jsp-config>

Warning: xmlns:c="http://java.sun.com/jstl/core" throws exception, collected in my h:messages Tag



来源:https://stackoverflow.com/questions/2373592/how-do-you-use-jstl

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