http://www.shangxueba.com/jingyan/1849061.html
来源:互联网 发布:学高等数学的软件 编辑:程序博客网 时间:2024/06/06 04:22
出现Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
我把jstl版本从1.0换成了1.2结果就好了,不明白什么原因,看了别人写的下边的才明白
The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar
可能一:
web项目出现如上问题,据查是版本问题:
JSTL 1.0 的声明是:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core " %>
JSTL1.1 的声明是:
<%@ taglib prefix="c" uri=http://java.sun.com/jsp/jstl/core %>
项目中,已经是 jstl 1.2 版本了,页面中也全部是用<%@ taglib prefix="c" uri=http://java.sun.com/jsp/jstl/core %>这种方式。javaee5之后就只有 jstl.jar 这一个jar包了,没有standard.jar包,tld文件也打包到jar里面去了,啥在web.xml文件里配置jsp-config的解决方式也是浮云。
可能二:
最终查到问题是 jstl.jar 包在ide项目中有,但在tomcat发布的应用WEB-INF/lib下没有,这是工具发布项目的问题,复制一个jar包过去问题就解决了。
>>jstl.jar没有
使用jstl的文档,这里有篇文档:
http://www.mularien.com/blog/2008/04/24/how-to-reference-and-use-jstl-in-your-web-application/
How to Reference and Use JSTL in your Web Application
As a frequent contributor to the Spring Framework user forums, I have noticed a common trend among people new to Spring MVC – they really don’t understand how to use JSTL and EL in their Spring-driven JSPs.
Although Spring MVC supports flexibility in choosing a view technology, in my [back of the napkin] estimate, at least 80% of the time it is paired with JSP and JSTL. Unfortunately, since JSP was pushed out about 4-5 years ago, a lot of the information that you find on the web is extremely dated, often going back to JSTL 1.0 syntax (or, gasp, using scriptlets!). In this article I’ll clear up the confusion around how to use JSTL with various app servers and webapp versions.
Since JSP implementation and support varies widely among app server vendors (and versions of an app server), a lot of Spring MVC newbies get stuck just getting simple JSTL expressions to work. Since Spring relies on JSTL EL expressions for output of bound fields (assuming you’re not using the form. taglibs), people often wrongly assume that something is wrong with Spring when their Spring-bound data doesn’t show up on the page.
Here’s a hint: if you can’t get a simple (non-Spring-related!) expression like ${2+2} to work, no expressions will work! (In a properly functioning servlet container, the prior expression should output “4″ on the page).
I set out to take some common application server configurations, combine them with various flavors of JSP/JSTL support, and see what happened.
The Importance of Servlet Version and web.xml
Let us review the following reference table:
JSP/Servlet Version
Servlet VersionJSP VersionJSTL VersionJava EE Version
2.52.11.25
2.42.01.11.4
2.31.21.01.2
What Does this mean to me?
The most important thing is to figure out what version of the Java EE web stack (Servlet/JSP) you are using. There are 2 aspects that factor into this:
What version of Java EE / servlet spec does your servlet container support?
What version of Java EE / servlet spec have you declared in your deployment descriptor (web.xml)?
Here’s an example of what to look for in web.xml:
web-app-25 ...
You can see the ‘version=”2.5″‘ designation in here. This means that within this web application, we will be able to use JSP 2.1 and JSTL 1.2 features.
OK, How do I use JSTL in my Page?
A very common problem that I have seen with new Spring users is that they don’t understand how to reference the JSTL tag libraries on their pages. Important!: You need to identify the version of web application you are using first.
Web Application v2.5 and v2.4
To use EL Expressions: You do not need . Simply insert EL expressions onto the page: ${2+2}
To use JSTL tag libraries (c, fmt, etc): Reference as follows:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Web Application v2.3
To use EL Expressions: You do need . Raw EL expressions on the page will not work. e.g.
To use JSTL tag libraries (c, fmt, etc): Reference as follows:
<%@taglib prefix="c" uri="http://java.sun.com/jsp/core" %>
What about the _rt Taglibs Like core_rt?
The following type of URI will also work, in JSTL 1.2 and 1.1:
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
However, this is not desired. You should never have to reference the _rt versions of taglibs (e.g. core_rt).
Do I need to include a JSTL Implementation with my Web Application?
Obviously, there are a lot of application servers out there. I tested this with the following:
Tomcat 6.0
Tomcat 5.5
Tomcat 5.0
JBOSS 4.2
Glassfish 2
Of these, JBOSS and Glassfish ship with JSTL implementations out of the box. Tomcat does not ship with a JSTL implementation. I have previously blogged about this here.
I did not test other application servers, simply because these are the ones I most commonly see referenced in the Spring forums. Websphere is also used, but I didn’t have access to it (and, frankly, didn’t want to spend the 8 hours and tens of gigs of downloads it would take to install it ).
Testing Methodology
For those who are interested, here’s the testing methodology I used to come to the conclusions above.
I created 6 web applications. The 6 web applications are as follows:
webapp-25: Servlet version 2.5 declared in web.xml, JSTL RI not included in WEB-INF/lib
webapp-25-jstlri: Servlet version 2.5 declared in web.xml, JSTL 1.2 RI included in WEB-INF/lib
webapp-24: Servlet version 2.4 declared in web.xml, JSTL RI not included in WEB-INF/lib
webapp-24-jstl11: Servlet version 2.4 declared in web.xml, JSTL 1.1 RI included in WEB-INF/lib
webapp-23: Servlet version 2.3 declared in web.xml, JSTL RI not included in WEB-INF/lib
webapp-23-jstl10: Servlet version 2.3 declared in web.xml, JSTL 1.0 RI included in WEB-INF/lib
In each web application, I created 4 JSP pages with the following content:
Some simple math: ${2+2}
Some simple math with c:out:
Some simple math with c2:out:
You can see there are 3 tests in the page. The goal of the tests are as follows:
${2+2}: does inline EL evaluation work with this webapp version?
: is the ‘c’ namespace automatically provided by the container?
is the ‘c2′ namespace explicitly provided by the given taglib declaration? (see next section for how the c2 taglib is declared)
For each of the 4 JSP pages, I varied how the JSTL core taglib was declared:
test_no_taglib_decl.jsp: Contained no taglib declarations at all
test_c2_jsp_jstl_core_taglib_decl.jsp: Contained the taglib declaration:
<%@taglib prefix="c2" uri="http://java.sun.com/jsp/jstl/core" %>
test_c2_jstl_core_taglib_decl.jsp: Contained the taglib declaration:
<%@taglib prefix="c2" uri="http://java.sun.com/jstl/core" %>
test_c2_jstl_core_rt_taglib_decl.jsp: Contained the taglib declaration:
<%@taglib prefix="c2" uri="http://java.sun.com/jstl/core_rt" %>
In a typical scenario where the container supports JSP 2.0+, what you would expect to see is the following:
Some simple math: 4
Some simple math with c:out:
Some simple math with c2:out: 4
What Happens if You Have the Wrong Declarations
Some of the errors you may get if you don’t have things declared right:
On Tomcat
Declaring the wrong taglib:
org.apache.jasper.JasperException: /test_c2_jstl_core_taglib_decl.jsp(11,32) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
No JSTL implementation:
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
On JBOSS
Since JBOSS also uses the Apache Jasper JSP compiler, the errors are basically exactly the same as those listed above.
On Glassfish
org.apache.jasper.JasperException: /test_c2_jstl_core_taglib_decl.jsp(11,32) PWC6236: According to TLD or attribute directive in tag file, attribute value does not accept any expressions
- http://www.shangxueba.com/jingyan/1849061.html
- http://www.shangxueba.com/jingyan/1866247.html
- http://jingyan.baidu.com/article/f96699bb8b38e0894e3c1bef.html
- http://jingyan.baidu.com/article/7f41ecec1b022e593d095c1e.html
- 转载http://jingyan.baidu.com/article/bad08e1e87138209c8512118.html
- http://jingyan.baidu.com/article/3065b3b6cc20f6becef8a44f.html
- http://jingyan.baidu.com/article/1709ad80a8caf14634c4f013.html
- xmanager使用方法http://jingyan.baidu.com/article/656db918f96e0ae381249c8c.html
- phpmyadmin出现#2003服务器无响应解决方法小结 http://jingyan.baidu.com/article/7c6fb428734c0980642c902e.html
- yii框架(yii framework)的部署方法 http://jingyan.baidu.com/article/5552ef472f6ec7518ffbc9d7.html
- windows下桌面共享(cp:http://jingyan.baidu.com/article/fea4511a455f17f7bb9125d7.html)
- 如何建立二叉搜索树 http://jingyan.baidu.com/article/c910274bfb701ecd361d2deb.html
- U盘多个分区合并起来的教程 http://jingyan.baidu.com/article/9989c7461be945f648ecfe3e.html
- C++ 自定义namespace的使用技巧 http://jingyan.baidu.com/article/b7001fe19399fa0e7282ddb3.html
- JDK1.7安装和环境配置http://jingyan.baidu.com/article/ff41162596a77912e4823716.html
- NetBeans IDE:[3]java安装路径改变http://jingyan.baidu.com/article/e52e36154149ec40c60c51a9.html
- SQL Server2008如何设置开启远程连接http://jingyan.baidu.com/article/fec4bce226a264f2618d8ba5.html
- 在虚拟机vmware workstation10上安装centos7步骤(http://jingyan.baidu.com/article/eae0782787b4c01fec548535.html)
- AWG标准
- 一堂价值39万元的课,把它看完,你一定会有收获
- 判断任意两台计算机的IP地址是否属于同一子网络
- webservice的调用
- 黑马程序员 -- Java基础学习(10)
- http://www.shangxueba.com/jingyan/1849061.html
- 《谁欠谁的幸福》2011高考满分作文
- Dorothy and the wizard in OZ 66%
- 勇者斗恶龙(BFS)
- Android 完美实现图片圆角和圆形(对实现进行分析)
- 太晚睡觉等于自杀,你晚上一般什么时候睡觉?
- 银行软件开发2年半,辞职后竟然找不到工作。
- java学习心得(一):代码的简单编译和解释的前期过程
- Hadoop学习<四>--HDFS的RPC通信原理总结