如何在Java Spring MVC中将Cookie“Path”属性的值设置为应用程序的实际虚拟目录路径

4zcjmb1e  于 2022-10-04  发布在  Java
关注(0)|答案(1)|浏览(209)

以下是我在web.xml中的配置

<session-config>
    <session-timeout>40</session-timeout>
    <cookie-config>
        <path>/</path>
    </cookie-config>
</session-config>

提前谢谢你

bnlyeluc

bnlyeluc1#

以下是答案Absolute path in mvc:resources/ instead of path relative to mapping of spring servlet

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="alwaysUseFullPath" value="true"/>
    <property name="mappings">
        <props>
            <prop key="/static/*">staticResources</prop>
        </props>
    </property>
</bean>

<bean id="staticResources" class="org.springframework.web.servlet.resource.ResourceHttpRequestHandler">
    <property name="locations">
        <list>
            <value>/WEB-INF/static/</value>
        </list>
    </property>
</bean>

相关问题