用servlet跳转到jsp页面跳不过去显示异常/main.jsp (行.: [14], 列: [33]) 属性值[request.getAttribute("array")]引用["],在值内使用时必须被转义。
public void home(HttpServletRequest request, HttpServletResponse response){
ArrayList arry =new ArrayList();
try{
Statement sta=jdbc.j();
ResultSet res=sta.executeQuery("select * from class");
while(res.next()){
cc c=new cc();
c.id=res.getInt("id");
c.name=res.getString("name");
arry.add(c);}
request.setAttribute("array",arry);
RequestDispatcher dispatcher=request.getRequestDispatcher("main.jsp");
dispatcher.forward(request,response);
}catch(Exception e){
System.out.println(e.getMessage());
}}
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Iterator" %>
<%@page import="cc"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>maintitle>
head>
<body>
<table>
<c:forEach var="e" items="<%=request.getAttribute("array")%>" >
<tr>
<td>${e.name}td>
<td>${e.id}td>
tr>
c:forEach>
table>
body>
html>
运行结果是啥也没有,异常信息是这样