私のSpring MVC
ウェブアプリケーションでは、ログインとログアウトにSpring Security
を使用します。私は、次のしている私のspring-security.xml
では次のようにSpring Security:ログアウト時にセッションからデータを取得する
<form-login login-page="/login" default-target-url="/"
authentication-failure-url="/login?error" username-parameter="username"
password-parameter="password" />
<logout logout-success-url="/login?logout" />
をログイン時には、私はセッションにユーザの詳細とTOを設定しています:
userTO
はタイプ
UserTO
のユーザの詳細を持つオブジェクトです
request.getSession().setAttribute("USERTO", userTO);
。以下のように、私のログアウトコントローラのメソッドは次のとおりです。
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(ModelMap model, @RequestParam(value = "error", required = false) String error, @RequestParam(value = "logout", required = false) String logout)
{
try
{
UserTO user = (UserTO) httpSession.getAttribute("USERTO");
if (error != null)
{
//error during login
}
if (logout != null)
{
//succesful logout
}
model.addAttribute("smartWCMLayoutID", "smartly");
model.addAttribute("cm", new CommonModel("", "", ""));
return "smartwcm.login.definition";
}
catch(Exception ex)
{
}
}
しかし、ログアウト時に、私は常にnullをUserTO
を取得します。ログアウトする前にセッションからそのvallueをキャプチャする方法はありますか?