相关疑难解决方法(0)

我可以关闭web.xml中的HttpSession吗?

我想完全消除HttpSession - 我可以在web.xml中这样做吗?我确信有容器特定的方法可以做到这一点(当我进行谷歌搜索时,搜索结果会出现这种情况).

PS这是个坏主意吗?在我真正需要它之前,我更喜欢完全禁用它们.

java session web.xml web-applications

55
推荐指数
3
解决办法
5万
查看次数

如何使spring boot永远不会发出会话cookie?

我正在使用spring boot开发Restful API服务器.我将项目配置为使用基本身份验证,如下所示.

@ComponentScan
@EnableAutoConfiguration
@EnableWebSecurity
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    ...
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.NEVER).and()
            .csrf().disable()
            .authorizeRequests().anyRequest().hasRole("USER").and()
            .httpBasic();
    }
    ...
}
Run Code Online (Sandbox Code Playgroud)

但是当我通过Chrome-Postman-Plugin测试API时,在第一次调用之后,服务器永远不需要用户凭据.我注意到'JSESSIONID'cookie已创建.

我的项目中没有其他安全配置.我想知道为什么会这样......

java spring spring-security

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