我有问题,当我得到attriubute,它包含null,但我赋给它的变量得到值
heres是perviouse页面我如何通过位置:
<%if(rs.next()) {%>
<td><a href="university.jsp?location=<%=rs.getInt("cs_id")%>"><%out.print((String) (rs.getString("country_state")));%></a></td>
<%}else{ break; } %>
这是没有获得参数的页面 请选择您的大学州或进入您的大学:
<%
//set the session the each parameter
String locationString = request.getParameter("location");
Integer locationId = Integer.valueOf(locationString);
session.setAttribute("locationId",locationString);
System.out.print(locationString);
System.out.print(request.getAttribute("locationId"));
%>
答案 0 :(得分:1)
您使用session.setAttribute("locationId", locationString);
将属性设置为session
但您尝试通过request
request.getAttribute("locationId")
获取属性
request.getAttribute
与session.getAttribute