gpt4 book ai didi

java - spring-boot web 应用程序中未考虑 web.xml session 超时?

转载 作者:行者123 更新时间:2023-11-28 22:49:20 25 4
gpt4 key购买 nike

我有一个 war webapp,它是用 spring-boot-starter-web 构建的,并在 tomcat8 上运行。

我只想为一个应用程序增加 session 超时。因此添加了以下文件:

/src/main/resources/WEB-INF/web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">

<session-config>
<session-timeout>600</session-timeout>
</session-config>
</web-app>

但 TTL session 超时仍然保持默认的 30 分钟。为什么?

最佳答案

在标准maven项目中,WEB-INF文件夹在src/main/webapp中,而不是在src/main/resources中。问题可能由此而来。

您检查打包的 war 文件以查找 web.xml 文件的位置。

您可以在这里找到示例项目结构:https://github.com/spring-projects/spring-boot/tree/v1.5.6.RELEASE/spring-boot-samples/spring-boot-sample-traditional

关于java - spring-boot web 应用程序中未考虑 web.xml session 超时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45819966/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com