2011-06-22 23 views
0

私はStrutsを初めて使っているので、簡単な質問があります。 LoginAction.javaに私は、StrutsとJSPでのセッションの使用

HttpSession session = request.getSession(true); 
... 
... 
session.setAttribute(authuser.getSess_userid(), "userid"); 
session.setAttribute(authuser.getSess_username(), "username"); 
session.setAttribute(authuser.getSess_access(), "usertype"); 
return mapping.findForward(SUCCESS); 
... 
... 

を次のように使用しているとのwelcome.jspに、

<p> <bean:message key="title.welcome_en" /> <%=session.getAttribute("username").toString()%> </p> 

はしかし、私はのwelcome.jspにNullPointExceptionを取得しています。私は間違って何をしていますか?

ありがとうございます。

答えて

2

それは

session.setAttribute("userid", authuser.getSess_userid()); 
session.setAttribute("username", authuser.getSess_username()); 
session.setAttribute("usertype", authuser.getSess_access()); 

http://download.oracle.com/javaee/5/api/javax/servlet/http/HttpSession.html#setAttribute(java.lang.String、私は愚かな感じさせるjava.lang.Object上位)

+1

マン、でなければなりません。私の目をチェックアウトするのが良い。ありがとう。 – Rabin

関連する問題