0
的JSTL代码下面应在此控制器的方法分析JSON文件基础:
控制器
@RequestMapping(value="listagem.json", method=RequestMethod.GET)
@PreAuthorize("hasPermission(#user, 'listagem_'+#this.this.name)")
public ModelAndView listagem_json(@RequestParam("pagina") String pagina, @RequestParam("items") String items, @RequestParam("ordem") String ordem) {
ModelAndView mav = new ModelAndView();
mav.setViewName("listagem");
mav.addObject("lista", serv.listagem(pagina, items, ordem));
mav.addObject("map", serv.getListaAtributos());
return mav;
}
JSTL代码
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="json" uri="http://www.atg.com/taglibs/json" %>
<json:object>
<json:array name="item" var="item" items="${lista}">
<json:object>
<c:forEach var="attr" items="${map}">
<c:choose>
<c:when test="${empty attr.value}">
<json:property name="${attr.key}" value="${item[attr.key]}"/>
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${item.class.name == 'List'}">
<json:array name="${attr.key}" var="attr2" items="${item[attr.key]}">
<json:object>
<c:forEach var="attr3" items="${attr.value}">
<json:property name="${attr3}" value="${attr2[attr3]}"/>
</c:forEach>
</json:object>
</json:array>
</c:when>
<c:otherwise>
<json:array name="${attr.key}">
<json:object>
<c:forEach var="attr2" items="${attr.value}">
<c:set value="${attr.key}" var="object"/>
<json:property name="${attr2}" value="${object}.${attr2}"/>
</c:forEach>
</json:object>
</json:array>
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
</c:forEach>
</json:object>
</json:array>
</json:object>
但是当我运行的应用程序和JSON文件要求,这个错误HAP笔:
org.apache.jasper.JasperException: /WEB-INF/json/listagem.jsp (line: 13, column: 9) "${item.class.name == 'List'}" contains invalid expression(s): javax.el.ELException: Failed to parse the expression [${item.class.name == 'List'}]
谁能告诉我什么是正确的方式来写这个表达式${item.class.name == 'List'}
为达到预期的结果?
$ {item.class.simpleName == “列表”} –