web.xml spring-boot web 应用程序中未考虑会话超时?
web.xml session-timeout not taken into account in spring-boot web app?
我有一个 war
网络应用程序,它是使用 spring-boot-starter-web
构建并在 tomcat8
.
上运行的
我只想为一个应用程序增加会话超时。因此添加了以下文件:
/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会话超时仍然是默认的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
我有一个 war
网络应用程序,它是使用 spring-boot-starter-web
构建并在 tomcat8
.
我只想为一个应用程序增加会话超时。因此添加了以下文件:
/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会话超时仍然是默认的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