尝试访问具有多个值的参数时出现EL错误

时间:2013-12-21 03:45:54

标签: java jsp el

<form action=”TestBean.jsp”>
Name: <input type=”text” name=”name”>
ID#: <input type=”text” name=”empID”>
First food: <input type=”text” name=”food”>
Second food: <input type=”text” name=”food”> 
<input type=”submit”> 
</form>

在jsp中我试图这样做

First food request param: ${param.food[0]} <br>
Second food request param: ${param.food[1]} <br>

当我尝试运行它时,我收到此错误

javax.el.PropertyNotFoundException: Property '0' not found on type java.lang.String

1 个答案:

答案 0 :(得分:0)

我正在尝试

First food request param: ${param.food[0]} <br>
Second food request param: ${param.food[1]} <br>

而不是

First food request param: ${paramValues.food[0]} <br>
Second food request param: ${paramValues.food[1]} <br>

将param.food [0]更改为paramValues.food [0]解决了这个问题。