避免在 Spring 中创建会话

Avoid create session in Spring

我有一个 Spring 网络应用程序,它会根据每个请求创建一个会话,我想避免这种情况。

我有这样的配置:

<security:http pattern="/**" auto-config='true' create-session="never" use-expressions="true">
    <security:intercept-url pattern="/**" access="permitAll" />
</security:http>

<security:authentication-manager>
    <security:authentication-provider>
        <security:jdbc-user-service data-source-ref="dataSource"/>
    </security:authentication-provider>
</security:authentication-manager>

然后我调用控制器

@RequestMapping(method=RequestMethod.GET, value="/experiences", produces="application/json")
public String getExperiencesList(
        HttpServletRequest request,
        @RequestParam(value = "channel",required=true) String channel,
        @RequestParam(value = "page",required=true) int page,
        Model model) {  
    String path = "http://" + HOST + request.getContextPath();
    model.addAttribute("json", experienceService.getExperiencesList(page,channel,path));

    return "json";
}

这将通过移动应用程序使用,同一个应用程序可以打开无限会话,知道如何避免这种情况吗?

谢谢。

好的,完成了,我重新构建了安全性并添加了一些更改。

在其他文件中添加了安全配置:

<http pattern="/**" security="none" create-session="never"/>

在web.xml中:

<http create-session="never"></http>

并在 jsp 页上添加了 session="false"。

现在似乎可以正常工作了。