首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

struts2 session传值后jsp跳转出错有关问题

2013-09-11 
struts2 session传值后jsp跳转出错问题actionString a this.admin.getUsername()ServletActionContext.

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.myexception.cn/j2se/33144.html

热点排行