日期:2014-05-18  浏览次数:20704 次

jsp中字符串赋值的错误????急救!!!
先贴一下代码:
<%  
UserContainer     nameContainer=(UserContainer)session.getAttribute( "USER ");
String   usertemp=(String)nameContainer.UserName;
      int userPurview=nameContainer.Type;
String   isAudit=null;
…………
%>

UserContainer类的定义
public   class   UserContainer
{
public int Index;
public String UserName;
public String Password;
public int Type;
public int BorderType;
……
}

用的是tomcat架设的服务器
给出的错误提示是;

org.apache.jasper.JasperException:   An   exception   occurred   processing   JSP   page   /admin/left.jsp   at   line   15

12:   <link   href= "/css/style.css "   rel= "stylesheet "   type= "text/css ">
13:   <%  
14:   UserContainer     nameContainer=(UserContainer)session.getAttribute( "USER ");
15:   String   usertemp=(String)nameContainer.UserName;
16:         int userPurview=nameContainer.Type;
17:   String   isAudit=null;
18:   int   tBID=nameContainer.BorderType;


我的session中的USER没有初始值   直接获取
为什么15行会出问题


------解决方案--------------------
if(nameContainer != null)
String usertemp=(String)nameContainer.UserName;
我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.aiyiweb.com/j2se/33144.html