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

时间:2013-12-28 19:57:17

标签: java html mysql sql jsp

JSP,SQL专家,我很感激我以前的所有帖子都有工作解决方案,因为我是上述编程语言的新手,只有基本的大学知识。通过命令行获取Java-SQL数据库数据提取后(为了基本了解JDBC),我已经转回“JSP-SQL数据库访问”。 这是我的第一个例子,但当我尝试执行它时,我收到一条XML错误消息,我猜是关于基于角色的身份验证虽然我不是确定即可。请向我提供帮助,最好是解决方案的基本步骤 以下是错误消息。

HTTP Status 500 - 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

type Exception report

message 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

description The server encountered an internal error that prevented it from fulfilling this request.

exception

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:56)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:445)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:117)
org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:311)
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:152)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:410)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:475)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1427)
org.apache.jasper.compiler.Parser.parse(Parser.java:138)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:242)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:102)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.47 logs.
Apache Tomcat/7.0.47  

这是JSP代码:

<%@ page import="java.io.*, java.util.*, java.sql.*" %>  
<%@ page import="javax.servlet.http.*, javax.servlet.*" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>    
<html>
<head>
  <title>SELECT operation</title>
</head>
<body>

<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
     url="jdbc:mysql://localhost/EMP"
     user="root" password="password"/>

<sql:query dataSource="${snapshot}" var="result">
SELECT * from Employees;
</sql:query>

<table border="1" width="100%">
<tr>
<th>Emp ID</th>
<th>Age</th>
<th>First Name</th>
<th>Last Name</th>

</tr>
<c:forEach var="row" items="${result.rows}">
<tr>
<td><c:out value="${row.id}"/></td>
<td><c:out value="${row.age}"/></td>
<td><c:out value="${row.first}"/></td>
<td><c:out value="${row.last}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html>  

以下是文件和类路径:
JSP页面:C:\ Program Files \ Apache Software Foundation \ Tomcat 7.0 \ webapps \ jsp pages \ RegName.jsp

CLASSPATH: C:\ Program Files \ Apache Software Foundation \ Tomcat 7.0 \ lib \ jsp-api.jar; C:\ glassfish3 \ jdk \ jre \ lib; C:\ Program Files( x86)\ MySQL \ MySQL Connector J \ mysql-connector-java-5.1.27-bin.jar

JAVA_HOME: C:\ glassfish3 \ jdk

路径: C:\ glassfish3 \ jdk \ bin; C:\ Program Files(x86)\ MySQL \ MySQL Server 5.0 \ bin

2 个答案:

答案 0 :(得分:4)

迟到的答案,但它可以帮助其他人!

如上所述here,您可以添加到您的pom.xml:

<dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>

它对我有用!

答案 1 :(得分:1)

您需要将jstl库添加到类路径中。通常,它会进入WEB-INF/lib。您可以获取二进制jar here