【问题标题】:http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this applicationhttp://java.sun.com/jsp/jstl/core 无法在 web.xml 或随此应用程序部署的 jar 文件中解析
【发布时间】:2013-01-31 21:51:10
【问题描述】:

我是 jsp web 开发的新手,调试我的应用程序以便能够读取数据库会出现以下错误:

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

我在多个网站上就这个问题在互联网上研究了很长时间,但无法解决任何问题。这些是我的规格:

IDE:日食/ JSP版本:2.0/ 小服务程序版本:2.4/ JSTL 版本:1.1.1/ Tomcat版本:7.0.35/

这是我的 WEB-INF/web.xml 文件

<?xml version="1.0" encoding="UTF-8" ?>
  <web-app 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 web-app_2_4.xsd"
version="2.4">  
  <resource-ref>
    <description>Resource configuration for database connection</description>
    <res-ref-name>jdbc/TestDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>
 </web-app>

这是我的 META-INF/context.xml 文件

<?xml version="1.0" encoding="UTF-8" ?>
<Context>
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
           maxActive="100" maxIdle="30" maxWait="10000"
           username="admin" password="admin" driverClassName="com.mysql.jdbc.Driver"
           url="jdbc:mysql://localhost:3306/checklist_pdnf"/>

 </Context>

这是我的jsp文件

<?xml version="1.0" encoding="UTF-8" ?>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

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

<sql:query var="db" dataSource="jdbs/TestDB">
select * from patient
</sql:query>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>    
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
<body>  
<div>
         <table>
    <c:forEach var="row" items="${db.rows}">    
            <tr>
            <td>row.getString("patient_medicalRecordNumber")</td>
            <td>row.getString("patient_lastName")</td>
            <td>row.getString("patient_firstName")</td>
            <td>row.getString("patient_middleName")</td>
            <td>row.getString("patient_dateOfBirth")</td>
            <td>row.getString("patient_gender")</td>
            <td>row.getString("patient_admissionDateTime")</td>
            <td>row.getString("patient_dischargeDateTime")</td>
            <td>row.getString("patient_attendingPhysician")</td>
            <td>row.getString("patient_locationRoom")</td>
        </tr>
    </c:forEach>    
     </table>
   </div> 
 </body>
</html>

【问题讨论】:

标签: mysql eclipse jsp tomcat jstl


【解决方案1】:

原来我的 JSP 版本实际上是 2.2,我记得在 Eclipse 中打开了一个 about 页面以获取此信息,但无法重新找到它以进行回答。但是,如有必要,我会相应地更新此答案。

使用的库:

(1) javax.servlet.jsp.jstl-1.2.1.jar

(2) javax.servlet.jsp.jstl-api-1.2.1.jar

(3) javax.servlet-api-3.0.1.jar

(4)mysql-connector-java-5.1.23-bin.jar

pom.xml 引用自http://java.net/projects/jsp/sources/svn/content/trunk/impl/pom.xml?rev=1440

依赖的版本是:

a) javax.servlet-api 3.1。 (b) javax.el-api 2.2.1。 (c) javax.servlet.jsp-api 1.2.1 (d) javax.servlet.jsp.jstl-api 1.2.1。 (e) jstl 1.2。 (f) jstl-imp 1.2。

web.xml 中的引用:

`<web-app  
  xmlns="http://java.sun.com/xml/ns/javaee" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> `

【讨论】:

    【解决方案2】:

    根据该链接,您是否按照以下说明进行操作?

    该 JSP 页面使用 JSTL 的 SQL 和 Core 标记库。您可以从 Apache Tomcat Taglibs - 标准标签库项目中获得它 - 只需确保您获得 1.1.x 或更高版本。拥有 JSTL 后,将 jstl.jar 和 standard.jar 复制到 Web 应用的 WEB-INF/lib 目录。

    【讨论】:

    • 是的。这是我的规格: IDE:eclipse JSP 版本:2.0 Servlet 版本:2.4 JSTL 版本:1.1.1 Tomcat 版本:7.0.35
    • 我已经添加了这两个库。我只是不确定这是否是 Tomcat 的版本问题。
    • 不确定是什么原因造成的,如果您提取这些罐子,您会看到其中存在 tld。另一种方法是在 WEB-INF/tlds 文件夹中显式添加这些 tld,并在 web.xml 中引用它们,您可以参考这个 [roseindia.net/jstl/downloading-jstl.shtml]
    • 原来是jsp版本和相关servlet版本参考等问题。非常感谢大家的帮助。我会尽快添加答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 1970-01-01
    • 2013-10-21
    • 1970-01-01
    相关资源
    最近更新 更多