MySQL http://java.sun.com/jsp/jstl/core 无法在 web.xml 或使用此应用程序部署的 jar 文件中解析

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14902875/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:35:43  来源:igfitidea点击:

http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

mysqleclipsejsptomcatjstl

提问by naddnan

I am new to jsp web development and debugging my application to be able to read off a database gives the following error:

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

I researched the internet on multiple sites regarding this issue for so long, unable to fix anything. These are my specs:

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

IDE: eclipse/ JSP version: 2.0/ Servlet version: 2.4/ JSTL version: 1.1.1/ Tomcat version: 7.0.35/

IDE:eclipse/ JSP 版本:2.0/ Servlet 版本:2.4/ JSTL 版本:1.1.1/ Tomcat 版本:7.0.35/

This is my WEB-INF/web.xml file

这是我的 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>

This is my META-INF/context.xml file

这是我的 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>

And this is my jsp file

这是我的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>

回答by naddnan

Turns out my JSP version was in fact 2.2, I remember opening up an about page in Eclipse to be able to get this information, but was not able to re find it for answering purposes. However, I will update this answer accordingly if necessary.

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

Libraries used:

使用的库:

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

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

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

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

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

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

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

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

pom.xml referenced from http://java.net/projects/jsp/sources/svn/content/trunk/impl/pom.xml?rev=1440

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

The versions of the dependencies are:

依赖项的版本是:

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.

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。

Reference in web.xml:

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

回答by stack user1

As per that link, did you follow the below instruction ?

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

That JSP page makes use of JSTL's SQL and Core taglibs. You can get it from Apache Tomcat Taglibs - Standard Tag Library project — just make sure you get a 1.1.x or later release. Once you have JSTL, copy jstl.jar and standard.jar to your web app's WEB-INF/lib directory.

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