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

请教个关于session.getattribute的问题
在加入session.setAttribute( "type ",level)时候     这个level是string类型的数字1,2..
但是在得到的时候int   a=((Integer)session.getAttribute( "type ")).intValue();
然后在判断if(a==1)或者if(a==2)但是抱错不是很明白那里错了,,开始我用string类型的,但是判断不了..希望高手帮下...或者告诉我该怎么做..我要判断这个取出来的数是多少...

------解决方案--------------------
int a=Interger.parseInt(session.getAttribute( "type "));
如果以上还行的话,就:
int a=Interger.parseInt(String.valueOf(session.getAttribute( "type ")));
然后:
if(a==1)
...
...