Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法运行jsp文件jstl_Java_Html_Jsp - Fatal编程技术网

Java 无法运行jsp文件jstl

Java 无法运行jsp文件jstl,java,html,jsp,Java,Html,Jsp,我是jsp新手,在运行这个emp.jsp文件时遇到了一个奇怪的问题。我知道这是非常基本的,但我现在被困了两天:P <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@taglib uri

我是jsp新手,在运行这个
emp.jsp
文件时遇到了一个奇怪的问题。我知道这是非常基本的,但我现在被困了两天:P

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>JSP Page</title>
</head>
<body>
    <sql:setDataSource var="connection" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/tutorials" user="root" password="" />
    <sql:query var="result" dataSource="${connection }">
        select * from registration
    </sql:query>

    <table border="0" width="75%">
        <tr>
            <th>id</th>
            <th>name</th>
            <th>password</th>
            <th>usertype</th>
        </tr>
        <c:forEach var="col" items="${result.rows }">
        <tr>
            <td><c:out value="${col.id}"></c:out></td>
            <td><c:out value="${col.name}"></c:out></td>
            <td><c:out value="${col.password}"></c:out></td>
            <td><c:out value="${col.usertype}"></c:out></td>
        </tr>
        </c:forEach>
    </table>
</body>
</html>
这是@rajani询问的我的web.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>Tutorials</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

教程
index.jsp

确保类路径上有jstl依赖项:

如果您使用的是Maven,请确保您对jstl工件具有依赖关系:

<dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
</dependency>

javax.servlet
jstl
1.2

jstl.jar添加到
WEB-INF/lib
目录。

此异常表明运行时类路径中缺少jstl API。您似乎只有JSTL impl。我建议删除它并使用jstl-1.2.jar,它同时绑定了API和impl

另见:


我现在真的不知道怎么做,你能告诉我怎么做吗我正在使用eclipsejavax.servlet.jsp.jstl-1.2.1.jar这个文件添加到我的web inf/lib中,工作正常你没有在SQL配置中指定密码,你能显示web.xml吗?@DhruvParashar你说javax.servlet.jsp.jstl-1.2.1.jar这个文件包含在项目中,是吗?如果是,那么也添加jstl-1.2.jar。javax.servlet.jsp.jstl-1.2.1.jar不包含所有必需的类从这里下载并在清理和构建后再次尝试执行添加这些新的jar并清理项目后现在显示新的错误,找不到sql的标记处理程序类:queryRemove jstl sql标记来自jsp,它们永远不会出现在jsp文件中,将它们传输到Sevlet,向请求添加数据,并使用getRequestDispatcher()方法呈现JSP。您在项目中使用Maven吗?它仅在web inf/lib中,不,我现在不知道如何使用Maven。您可以再次检查是否复制了所有必需的jar文件吗??Servelt-api.jar、jsp-api.jar和jstl-jar文件Servlet-api.jar和jsp-api.jar不在我的项目中,尽管我已经包含了mysql-connector.jar和jstl1.2.jar,我想它们不需要Servlet-api.jar,从java连接到数据库需要jsp-api.jarmysql-connector.jar文件。服务器端剩下的两个jar文件(Servlet-api.jar和jsp-api.jar)。如果没有这些jar文件,Tomcat将无法运行您的web项目。请加上这两个罐子试试。
<dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
</dependency>