addLeagueServlet.java
String leagueName = request.getParameter("name");
int leagueYear = Integer.parseInt(request.getParameter("yearleague"));
String leagueSeason = request.getParameter("season");
League league = new League(leagueYear, leagueSeason, leagueName);
leagueList.add(new League(leagueYear, leagueSeason, leagueName));
request.setAttribute("leagueList", leagueList);
out.print("League successfully added!<br>");
out.print("<a href='Landing.jsp'>Home</a>");
listLeagues.java
Iterator iter = ((LinkedList)request.getAttribute("leaguelist")).iterator();
League league = (League)iter.next();
while(iter.hasNext())
out.print(league.getName());
因此,当我单击jsp中的Listtheleages链接时,它会显示null指针异常。请告诉我如何将linkedlist从addleaguelist传递到listleaguess servlet。谢谢
在代码中键入。已将属性添加为"leagueList"。正在尝试以"leagueList"检索。