我试图在java中学习Expression Languages和JSTL。 因此,在网上学习时,我在网上找到了一个代码,演示了表达式语言和JSTL的使用。 所以我现在已经掌握了它的基本内容。但是当我试图在我的电脑上运行代码时,它会抛出一些我无法理解的异常。
两个jsp代码是 -
1. index.jsp
<html>
<head>
<title>EL Implicit Objects: Request Parameters</title>
</head>
<body>
<form action='paramm.jsp'>
<table>
<tr>
<td>First Name:</td>
<td><input type='text' name='firstName'/></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' name='lastName'/></td>
</tr>
<tr>
<td>
Select languages that you have worked with:
</td>
<td>
<select name='languages' size='7'
multiple='true'>
<option value='Ada'>Ada</option>
<option value='C'>C</option>
<option value='C++'>C++</option>
<option value='Cobol'>Cobol</option>
<option value='Eiffel'>Eiffel</option>
<option value='Objective-C'>
Objective-C
</option>
<option value='Java'>Java</option>
</select>
</td>
</tr>
</table>
<p><input type='submit' value='Finish Survey'/>
</form>
</body>
</html>
和第二个文件, 2。 paramm.jsp
<html>
<head>
<title>Accessing Request Parameters</title>
</head>
<body>
<%@ taglib uri='http://java.sun.com/jstl/core' prefix='c' %>
<font size='5'>
Skillset for:
</font>
<%-- Access the lastName and firstName request parameters
parameters by name --%>
<c:out value='${param.lastName}'/>
<c:out value='${param.firstName}'/>
<%-- Show all request parameters and their values --%>
<p><font size='5'>
All Request Parameters:
</font><p>
<%-- For every String[] item of paramValues... --%>
<c:forEach var='parameter' items='${paramValues}'>
<ul>
<%-- Show the key, which is the request parameter
name --%>
<li><b><c:out value='${parameter.key}'/></b>:</li>
<%-- Iterate over the values -- a String[] --
associated with this request parameter --%>
<c:forEach var='value' items='${parameter.value}'>
<%-- Show the String value --%>
<c:out value='${value}'/>
</c:forEach>
</ul>
</c:forEach>
<%-- Show values for the languages request parameter --%>
<font size='5'>
Languages:
</font><p>
<%-- paramValues.languages is a String [] of values for the
languages request parameter --%>
<c:forEach var='language' items='${paramValues.languages}'>
<c:out value='${language}'/>
</c:forEach>
<p>
<%-- Show the value of the param.languages map entry,
which is the first value for the languages
request parameter --%>
<c:out value="${'${'}param.languages} = ${param.languages}"/>
</body>
</html>
此处的错误位于paramm.jsp的第21行
<c:out value='${param.lastName}'/>
<c:out value='${param.firstName}'/>
exception- org.apache.jasper.JasperException:/paramm.jsp(21,26)PWC6236:根据标记文件中的TLD或属性指令,属性值不接受任何表达式