我正在使用 spring 3.2.8.RELEASE 和 tomcat 7.0.55 实现一个 Web 应用程序。
我需要 spring 对某些请求使用 https,例如“/login”,但不是对所有请求。
应用程序在 http 和 https 上完美运行,但我想过滤一些请求以自动在 https 上运行。
我如何配置 spring 来执行此操作?
最佳答案
您可以通过添加 requires-channel- attribute 来配置需要 https在每个拦截网址上。
例如:
<security:intercept-url pattern="/your_url" access="your_role" requires-channel="https"/>
编辑:
web.xml 中所需的 spring 安全映射:
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我希望这会奏效。
关于java - spring如何自动使用https请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31893074/