读书人

JSTL 的有关问题(According to TLD or

发布时间: 2012-11-01 11:11:33 作者: rapoo

JSTL 的问题(According to TLD or attribute directive in tag file, attribute value do

环境: win2003 tomcat 5.5 JDK1.6上

<?xml?version="1.0"?encoding="UTF-8"?>
<web-app?version="2.4"
?????????xmlns="http://java.sun.com/xml/ns/j2ee"
?????????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
?????????xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee?http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"?>

</web-app>

jsp代码:

JSTL 的有关问题(According to TLD or attribute directive in tag file, attribute value doJSTL 的有关问题(According to TLD or attribute directive in tag file, attribute value do<%JSTL 的有关问题(According to TLD or attribute directive in tag file, attribute value do@taglib?prefix="c"?uri="http://java.sun.com/jsp/jstl/core"?%>????
JSTL 的有关问题(According to TLD or attribute directive in tag file, attribute value do???
JSTL 的有关问题(According to TLD or attribute directive in tag file, attribute value do1+2+3?=?${1+2+3}?<br>????
JSTL 的有关问题(According to TLD or attribute directive in tag file, attribute value do1+2+3?=?<c:out?value="6"?/>??<br>?
JSTL 的有关问题(According to TLD or attribute directive in tag file, attribute value do

此时执行没有任何问题。

?1+2+3 = <c:out value="${1+2+3}" />执行时就会出现:
According to TLD or attribute directive in tag file, attribute value does not accept any expressions

昨天少了一个jsp,所以一直出现问题。

代码

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

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

<script>render_code();</script>

?

今天再试。发现JSTL1.1可以用。但是用JSTL1.0时,出现问题。
就是把JSTL1.1的库放到/WEB-INF/lib/ 下。
刚开始我是netbeans 5.5.1中的JSTL库拷贝出来发现可以用。后来用jstl1.1.2的库,也是可以用。

总结:
JSTL1.1的库 在JSP2.0(Servlet 2.4)及以后(推荐用JSTL1.1及以上)用:

代码

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

<script>render_code();</script>
web.xml

<?xml?version="1.0"?encoding="UTF-8"?>
<web-app?version="2.4"
?????????xmlns="http://java.sun.com/xml/ns/j2ee"
?????????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
?????????xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee?http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"?>

</web-app>

?

<script>render_code();</script>

?

在 Servlet2.3及以前,

代码

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

<script>render_code();</script>
比2.4以后版本少了jsp
web.xml

<?xml?version="1.0"?encoding="UTF-8"?>???
<!DOCTYPE?web-app?PUBLIC?"-//Sun?Microsystems,?Inc.//DTD?Web?Application?2.3//EN"?"http://java.sun.com/dtd/web-app_2_3.dtd">???
<web-app>???
???????
</web-app>???

?

在Servlet2.3中最好用JSTL1.0,如果用JSTL1.1,请加上

?

在Servlet2.3中最好用JSTL1.0,如果用JSTL1.1,请加上

<?xml?version="1.0"?encoding="UTF-8"?>???
<!DOCTYPE?web-app?PUBLIC?"-//Sun?Microsystems,?Inc.//DTD?Web?Application?2.3//EN"?"http://java.sun.com/dtd/web-app_2_3.dtd">???
<web-app>????????
????<taglib>???
????????<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>???
????????<taglib-location>/WEB-INF/c.tld</taglib-location>???
????</taglib>???
</web-app>??


把tld目录下的c.tld拷贝到/WEB-INF?下。

?找到官方下载地址:
http://jakarta.apache.org/site/downloads/downloads_taglibs.html
选择 Standard 1.0 Taglib 和Standard 1.1 Taglib 可以下载jstl1.0和jstl1.1版本。

读书人网 >JavaScript

热点推荐