我是JSP和JSTL的新手,所以我可能在这里做了一些非常愚蠢的事情。评估为空字符串的EL表达式
我在我的webapps的lib目录下有javax.servlet.jsp.jstl-api-1.2.1和javax.servlet.jsp.jstl-1.2.1。我在Tomcat7上运行。如果它有什么区别,Eclipse正在启动tomcat。我的项目是一个“动态Web项目”。
的web.xml看起来是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<display-name>example</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
的index.jsp看起来像这样
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Example</title>
</head>
<body>
<%
String s = "Foo";
%>
<c:out value="${s}" />
<c:out value="Bar" />
</body>
</html>
我预计这将与Foo Bar
上显示的页面。相反,它只显示Bar
。这发生在我所有的EL表达式中。我所有的EL表达似乎都是空的。
[如果](http://docs.oracle.com/javaee /5/jstl/1.1/docs/tlddocs/c/out.html)你是否读过''已弃用? –
BalusC
2013-02-11 01:05:41
@BalusC我会发誓我在某处读过它,但找不到它,所以看起来我错了。从答案中删除了这个。 – 2013-02-11 12:24:02