Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/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
未在JSP中计算EL表达式_Jsp_El_Web.xml - Fatal编程技术网

未在JSP中计算EL表达式

未在JSP中计算EL表达式,jsp,el,web.xml,Jsp,El,Web.xml,我的servlets/jsp web应用程序有一个小问题。我试图在jsp页面中使用jstl。例如,当我使用任何标记时: <c:out value="${command}"/> 在我的浏览器中,而不是参数“命令”值。我正在使用maven(我想问题就在这里)。以下是pom xml依赖项: <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-

我的servlets/jsp web应用程序有一个小问题。我试图在jsp页面中使用jstl。例如,当我使用任何标记时:

<c:out value="${command}"/>
在我的浏览器中,而不是参数“命令”值。我正在使用maven(我想问题就在这里)。以下是pom xml依赖项:

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>javax.servlet-api</artifactId>
  <version>3.0.1</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>jstl</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
</dependency>
然后去

request.getRequestDispatcher(redir).forward(request, response);
请告诉我,我做错了什么! 谢谢

是的,我在web.xml中有doctype

web.xml
中删除该
,并确保
声明为符合Servlet 2.4或更高版本,并且一切正常

web.xml
兼容的有效Servlet 3.0(Tomcat 7、JBoss AS 6-7、GlassFish 3等)的完整性如下所示,没有任何


对于Servlet 3.1(Tomcat 8、WildFly 8-11、GlassFish/Payara 4等),它如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    version="4.0">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
    version="5.0">

    <!-- Config here. -->

</web-app>

对于Servlet 4.0(Tomcat 9、WildFly 12-21、GlassFish/Payara 5等),它如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    version="4.0">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
    version="5.0">

    <!-- Config here. -->

</web-app>

对于Servlet 5.0(Tomcat 10、WildFly 22、GlassFish/Payara 6等),它如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    version="4.0">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
    version="5.0">

    <!-- Config here. -->

</web-app>

当使用JSTL 1.1或更新版本时,您需要确保您的
web.xml
的声明方式使webapp至少在Servlet 2.4模式下运行,否则EL表达式在webapp中不起作用

如果在
web.xml
中仍然有Servlet 2.3或更早版本的
,即使您已经有Servlet 2.4或更高版本的XSD,它仍将被迫在Servlet 2.3或更早版本的MODU中运行,从而导致EL表达式失败

技术原因是,EL最初是JSTL1.0的一部分,在Servlet2.3/JSP1.2及更早版本中不可用。在JSTL1.1中,EL从JSTL中删除,并集成到JSP2.0中,后者与Servlet2.4一起使用。因此,如果您的
web.xml
被声明为在Servlet2.3或更旧的MODU中运行webapp,那么JSP将期望在JSTL库中找到EL,但如果它是一个新的JSTL版本,缺少EL,那么这将反过来失败

另见:
  • -关于EL的历史
是的,我在web.xml中有doctype

web.xml
中删除该
,并确保
声明为符合Servlet 2.4或更高版本,并且一切正常

web.xml
兼容的有效Servlet 3.0(Tomcat 7、JBoss AS 6-7、GlassFish 3等)的完整性如下所示,没有任何


对于Servlet 3.1(Tomcat 8、WildFly 8-11、GlassFish/Payara 4等),它如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    version="4.0">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
    version="5.0">

    <!-- Config here. -->

</web-app>

对于Servlet 4.0(Tomcat 9、WildFly 12-21、GlassFish/Payara 5等),它如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    version="4.0">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
    version="5.0">

    <!-- Config here. -->

</web-app>

对于Servlet 5.0(Tomcat 10、WildFly 22、GlassFish/Payara 6等),它如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
    version="4.0">

    <!-- Config here. -->

</web-app>
<?xml version="1.0" encoding="UTF-8"?>
<web-app 
    xmlns="https://jakarta.ee/xml/ns/jakartaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd"
    version="5.0">

    <!-- Config here. -->

</web-app>

当使用JSTL 1.1或更新版本时,您需要确保您的
web.xml
的声明方式使webapp至少在Servlet 2.4模式下运行,否则EL表达式在webapp中不起作用

如果在
web.xml
中仍然有Servlet 2.3或更早版本的
,即使您已经有Servlet 2.4或更高版本的XSD,它仍将被迫在Servlet 2.3或更早版本的MODU中运行,从而导致EL表达式失败

技术原因是,EL最初是JSTL1.0的一部分,在Servlet2.3/JSP1.2及更早版本中不可用。在JSTL1.1中,EL从JSTL中删除,并集成到JSP2.0中,后者与Servlet2.4一起使用。因此,如果您的
web.xml
被声明为在Servlet2.3或更旧的MODU中运行webapp,那么JSP将期望在JSTL库中找到EL,但如果它是一个新的JSTL版本,缺少EL,那么这将反过来失败

另见:
  • -关于EL的历史

对于web.xml文件(version=“3.0”),我必须在Tomcat服务器v.8而不是v.7上运行应用程序,否则我会遇到与您相同的问题。希望这对某人有帮助

<?xml version="1.0" encoding="ISO-8859-1" ?>
<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">

对于web.xml文件(version=“3.0”),我必须在Tomcat服务器v.8而不是v.7上运行应用程序,否则我会遇到与您相同的问题。希望这对某人有帮助

<?xml version="1.0" encoding="ISO-8859-1" ?>
<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">


在页面顶部设置
对我很有帮助。我不知道为什么这是我的问题的根源。还不清楚原因。

在页面顶部设置
对我有帮助。我不知道为什么这是我的问题的根源。还不清楚原因。

尝试将jdbc驱动程序类放在WEB-INF->lib文件夹中,并检查所使用的servlet和jar文件的版本。在我的例子中,我使用了mssql-jdbc-8.2.2.jar,并在pom.xml中对其进行了更新。请尝试将jdbc驱动程序类放置在WEB-INF->lib文件夹中,并检查所使用的servlet和jar文件的版本。在我的例子中,我使用了mssql-jdbc-8.2.2.jar,并在pom.xml中对其进行了更新,但我的JSP页面也无法识别。始终执行错误条件,即。这就是正在发生的事情

这是一个内部JSP页面,即

<jsp:include page="your-inner-page.jsp"/>

内部JSP是先加载的,没有下面的标记库。它们被放置在外部JSP上。将它们添加到内部对我很有效

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>

我的JSP页面也无法识别。始终执行错误条件,即。这就是正在发生的事情

这是一个内部JSP页面,即

<jsp:include page="your-inner-page.jsp"/>

内部JSP是先加载的,没有下面的标记库。它们被放置在外部JSP上。将它们添加到内部对我很有效

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>


您可以显示设置命令值的java代码吗?如果您也提供了jstl依赖项,这样它就不会与应用程序一起部署,会发生什么情况?@BalusC-是的,我在pom的web.xml“”中有doctype最后一个依赖项是junit。请删除该doctype,然后重试。@BalusC-成功了!!谢谢!!但是你能解释一下doctype失败的原因吗