小编Chi*_*hah的帖子

服务器重启后HttpSession仍然存在

我正在学习春天.执行登录/注销功能.这就是我的控制器的样子:

@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;

}
Run Code Online (Sandbox Code Playgroud)

登录是通过Spring Security使用我实现的dao服务执行的.这很好.

这是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/>
<%} %>
Run Code Online (Sandbox Code Playgroud)

当我登录并重新启动服务器时,我仍然登录.在服务器重启后,会话信息是否应该丢失?如果我重新启动浏览器,它将按预期工作(即会话信息丢失).

这是我的Spring Security配置:

<http auto-config="true"  use-expressions="true">
        <intercept-url pattern="/" access="permitAll" />
        <intercept-url pattern="/logout" …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-security httpsession

3
推荐指数
2
解决办法
8744
查看次数

这个代码是哪种排序技术?

有人让我对数组进行排序,我做了如下操作.现在我们正在争论这是哪种排序技术.在向我解释他所知道的不同分类技术之后,他将其归类为泡泡,但我认为不是!但它确实排序!

C代码:

void sort(void){

int a[9]={4,2,1,3,5,7,5,6,8};
int i,j,temp;

for(i=0;i<9;i++)
{
    for(j=0;j<i;j++)
    {
        if(a[j] > a[i])
        {
            temp = a[i];
            a[i] = a[j];
            a[j] = temp;
        }
    }

}

for(i=0;i<9;i++)
{
    printf("\n%d",a[i]);
}
}
Run Code Online (Sandbox Code Playgroud)

根据他同意的我所说的这是泡沫,但也将前者归为同样的.我的意思是必须有一个名字!

for(i=0;i<9;i++)
{
    for(j=0;j<8;j++)
    {
        if(a[j] > a[j+1])
        {
            temp = a[j+1];
            a[j+1] = a[j];
                a[j] = temp;
        }
    }    

}
Run Code Online (Sandbox Code Playgroud)

c sorting bubble-sort

2
推荐指数
1
解决办法
207
查看次数