我是 JSP 新手并使用表达式语言。我正在使用带有 2.5 版和 Tomcat 6 服务器的 Eclipse Galileo。我只是想问一下,我的简单表达式语言不会像我写的那样打印 vale ${1>2}
,假设它会给出 false,但它 ${1>2}
仅在呈现页面时才显示。但是当我使用<c:out value="${1>2}"/>
它时,它会正确打印错误。我认为标签库存在问题。请建议我这样做的原因,我为此提供了一个示例代码,以便您了解我哪里出错了:-
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<!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>Expression Language Example</title>
</head>
<body>
Is 1 greater than 2 using cout :<c:out value="${1>2}"/>
Is 1 greater than 2 without using cout: ${1>2}
</body>
</html>
根据答案更新,这里有更多信息:
我正在展示我的web.xml
样子:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>ScriptLessJsp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<description></description>
<display-name>ElServlet</display-name>
<servlet-name>ElServlet</servlet-name>
<servlet-class>com.servlet.El.ElServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ElServlet</servlet-name>
<url-pattern>/ElServlet</url-pattern>
</servlet-mapping>
<servlet>
<description></description>
<display-name>Collections</display-name>
<servlet-name>Collections</servlet-name>
<servlet-class>com.servlet.El.Collections</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Collections</servlet-name>
<url-pattern>/go</url-pattern>
</servlet-mapping>
</web-app>
在我的 lib 文件夹中,我只添加了jstl.jar
这样我可以使用<c:out>
标签来显示,但我的模板文本的 EL 不起作用。