日期:2014-05-19  浏览次数:20671 次

struts2 session传值后jsp跳转出错问题
action
String a = this.admin.getUsername();

ServletActionContext.getRequest().getSession().setAttribute("username", a);//把值存入session
jsp

  <tr>
  <% String username = (String)ServletActionContext.getRequest().getSession().getAttribute("username");%>
  <td height="69" align="right" valign="bottom">当前登录用户:<%=username %></td>
  </tr>

登录后能显示用户名,跳转到其它页面就显示上面2条jsp语句出错org.apache.jasper.JasperException: An exception occurred processing JSP page

我这样写不是已经把username存入session了吗,页面跳转应该也不影响之前存入的参数啊?

------解决方案--------------------
<% String username = (String)ServletActionContext.getRequest().getSession().getAttribute("username");%>
直接用session.getAttribute("username");

内置对象,前面加那么多,解析成java文件的时候会不会出错,你去服务器 里面work文件夹看看.java


我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.aiyiweb.com/j2se/33144.html