HttpSession bleibt nach server-Neustart

Ich Lerne Frühjahr. Tun die login/logout-Funktionalität.
Dies ist, was mein controller sieht so aus:

@RequestMapping(value="/successfulLoginAuth", method=RequestMethod.GET)
public ModelAndView postHttpLogin(HttpSession session, Authentication authInfo) 
{

ModelAndView mav = new ModelAndView();
mav.setViewName("redirect:/index.html");
session.setAttribute("authInfo", authInfo);

return mav;

}

Den log-in erfolgt über Spring Security mit einer dao-service, die ich umgesetzt haben. Das funktioniert auch.

Dies ist der Inhalt des index.jsp:

<% 
    HttpSession session1 = request.getSession(false);
    Authentication authInfo; 
    if( (session1 != null) && 
        ( (authInfo = (Authentication)session1.getAttribute("authInfo")) != null) 
      )
    {

        out.print(" yo " + authInfo.getName() + " " + authInfo.getAuthorities().iterator().next().getAuthority());
    }
    else
    {
%>    
<a href="${pageContext.request.contextPath}/registration">New? Sign Up!</a><br/>

<a href="${pageContext.request.contextPath}/login">Existing? Sign In!</a><br/>
<%} %>

Wenn ich log-in, und starten Sie den server neu, ich bin immer noch angemeldet. Sollte nicht die session-Informationen verloren gehen, nach einem Neustart des Servers? Wenn ich den browser neu starten, es funktioniert wie es soll (also die session-info verloren).

Dies ist mein Spring Security-Konfiguration:

<http auto-config="true"  use-expressions="true">
        <intercept-url pattern="/" access="permitAll" />
        <intercept-url pattern="/logout" access="permitAll" />
        <intercept-url pattern="/accessdenied" access="permitAll" />
        <form-login login-page="/login" default-target-url="/successfulLoginAuth" authentication-failure-url="/accessdenied" />
        <logout logout-success-url="/logout" />
    </http>

<authentication-manager>
    <authentication-provider user-service-ref="myUserDetailsService"></authentication-provider>
  </authentication-manager>
InformationsquelleAutor Chinmay Shah | 2013-09-27
Schreibe einen Kommentar