在學習JSTL時,報
17:31:13,469 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: /index.jsp(21,1) According to TLD or attribute directive in tag file, attribute value does not accept any expressions
其中web.xml的内容是:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
</web-app>
jsp頁面内容是:
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>
index.jsp
</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<c:out value="${userName}" escapeXml="false"/>
<form action="index.jsp" method="POST">
<table border="0">
<tr>
<td>
Login:
</td>
<td>
<input name="userName" size="12" maxlength="12" type="text"/>
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<input type="password" size="12" maxlength="12" name="password " />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit"/>
</td>
</tr>
</table>
</form>
</body>
</html>
原因是web.xml文件中的版本問題,把其中的version="2.4" 改爲"2.3",http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd改爲http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_3.xsd問題解決