我有一个 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/