我想understrand当我使用JSTL访问地图会发生什么,在Hidden features of JSP/Servlet 在@ blausC的回答,他解释发生了什么,但是当我尝试使用下面的代码概念
<c:set var="resultMap" value="validationResults" scope="request"></c:set>
<c:if test="${resultMap['userName'] != null}">
${resultMap['userName'].details}
</c:if>
一困惑例外happend
Caused by: javax.el.PropertyNotFoundException: Property 'userName' not found on type java.lang.String
地图的关键应该是字符串,所以whay就是这个例外,我试图在上面的问题,同样的异常的例子中,有一个人能告诉我,我有误解?
编辑:我填充在servlet的地图,并将其发送给在jsp
Map<String, ValidationResult> result = new HashMap<String, ValidationResult>();
aValidationResult = new ValidationResult();
check whether the field is valid or not if not fill the map
result.put("userName", aValidationResult);
result.put("group", aValidationResult);
如果地图不为空,则返回地图把jsp
request.setAttribute("validationResults", result);
地图充满时我做服务器端验证,
Thanx提前。
我怀疑这会是原因,但我该怎么处理map,因为它的键是字符串? – palAlaa 2010-12-17 04:04:01
你如何填充resultMap? – Enrique 2010-12-17 04:05:22
如果resultMap是java.util.Map或java.lang.String,您是否调试过? – gbakernet 2010-12-17 04:08:09