2010-03-03 79 views
10

嘗試使用JSTL,但有以下問題:你如何使用JSTL?

的index.xhtml頁:

<?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> 

輸出源:

 <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> 

,你可以看到它沒有處理c:out,只是將它作爲文本打印出來。

+0

和你的問題是? – mkoryak 2010-03-03 17:45:11

+1

它不處理c:只是打印它。 – 2010-03-03 17:48:40

+0

這是一個混合jstl和jsf的教程(http://www.devx.com/Java/Article/21020)。我希望它能幫助你。 – Aito 2010-03-03 17:58:07

回答

4

似乎:

的解決方案是從JSTL命名空間移除/ JSP:

的xmlns:C = 「http://java.sun.com/jstl/core」

看到這個post

+1

@BalusC啊......好的。我很快會刪除這篇文章。對不起,謝謝。 – Aito 2010-03-03 18:34:59

+1

我取消刪除帖子,直到@DD試一試並告訴我們它不起作用。然後,我會再次刪除它。 :) 問候 – Aito 2010-03-04 14:20:04

0

我可以在我的XHTML文件中添加 xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"解決問題。

OR

宣佈這在我的web.xml中,並從我的應用程序中複製/ WEB-INF/JSP的c.tld:

<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> 

警告: 的xmlns:c =「HTTP ://java.sun.com/jstl/core「拋出異常,收集在我的h:messages中標籤