当我使用mybatis从数据库查询数据,通过servlet返回到界面,发现jsp页面无法解析。
request.setAttribute("brands",brands);
request.getRequestDispatcher("/jstl-foreach.jsp").forward(request,response);
<c:forEach items="${brands}" var="brand" varStatus="status">
<tr align="center">
<%--<td>${brand.id}</td>--%>
<td>${status.count}</td>
<td>${brand.brandName}</td>
<td>${brand.companyName}</td>
<td>${brand.ordered}</td>
<td>${brand.description}</td>
<c:if test="${brand.status == 1}">
<td>启用</td>
</c:if>
<c:if test="${brand.status != 1}">
<td>禁用</td>
</c:if>
<td><a href="#">修改</a> <a href="#">删除</a></td>
</tr>
</c:forEach>
仔细检查后自己代码没有错误,网上搜了很多方法,最后终于解决.
原因:JSP和Servlet版本导致el功能默认关闭,加入<%@page isELIgnored="false"%>标签手动开启el功能。
解决方法:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%--加入该标签手动开启el功能--%>
<%@page isELIgnored="false"%>
在使用Mybatis查询数据并通过Servlet传递到JSP页面显示时,遇到JSP无法解析EL表达式的问题。原因是由于JSP和Servlet的版本导致EL功能默认关闭。解决这个问题的方法是在JSP页面中添加<%@pageisELIgnored=false%>标签,手动开启EL功能。

795

被折叠的 条评论
为什么被折叠?



