应用程序属性"server.servlet.session.timeout";在Spring Boot项目中不起作用 [英] Application property "server.servlet.session.timeout" is not working in Spring Boot project

查看:3438
本文介绍了应用程序属性"server.servlet.session.timeout";在Spring Boot项目中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Spring Boot的文档,可以通过设置

According to the documentation of Spring Boot, session timeout can be configured by setting

server.servlet.session.timeout= 300s

文件中的

.在这篇文章

in application.properties file. In this post and in Spring Boot documentation it is also said so. But unfortunately this is not working for me.

还有其他配置可以达到预期效果吗?

Is there any other configuration to get expected result?

推荐答案

我正在发布答案,因为这种情况对我来说是新的.而且我还没有逐步找到适当的解决方案. 根据M. Deinum的建议,我在WEB-INF文件夹下创建了一个web.xml文件.项目结构就像

I am posting answer because this scenario is new for me. And I haven't got proper solution step by step. According to the suggestion of M. Deinum I created a web.xml file under WEB-INF folder. Project structure is like

src
 |_ main
     |_ java
     |_ resources
     |_ webapp
         |_ WEB-INF
              |_ web.xml

web.xml中,我配置了<session-timeout>...</session-timeout>

我的web.xml就像

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         id="WebApp_ID" version="2.5">


    <session-config>
        <session-timeout>5</session-timeout>
    </session-config>

</web-app>

现在,我在服务器中的Web应用程序的会话时间正在根据我的配置进行工作.感谢去M. Deinum

And now session time of my webapp in server is working according to my configuration. Thanks goes to M. Deinum

这篇关于应用程序属性"server.servlet.session.timeout";在Spring Boot项目中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆