| 目次 |
|---|
|
・セッションコンテキストとは ・アクションフォームをセッションコンテキストに保存するアクションクラスの例 ・JSPの例 |
package com.confrage.loginAction;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.confrage.Login.Login;
public class loginAction extends Action{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) throws Exception{
Login login = (Login)form;
HttpSession session = req.getSession();
session.setAttribute("login" ,login);
return mapping.findForward("success");
}
}
<bean:write name="login" property="username" /> <bean:write name="login" property="password" />これで以下の赤線で囲んだ部分のようにユーザ名とパスワードが表示されます。
