java - 如何强制我在 Spring 中的所有页面使用 https 协议(protocol)

标签 java angularjs spring http https

<分区>

我下载了um应用程序的源代码并部署在Heroku中,虽然我不能运行它。

带有源代码的网站:http://websystique.com/springmvc/spring-mvc-4-angularjs-example/

Error Screenshot

最佳答案

Web 应用程序同时支持 HTTP 和 HTTPS。如果您想强制所有 URL 使用 HTTPS。您需要做的就是设置 requires-channel。 Spring Security 有一个简单的配置,允许我们将所有基于 HTTP 的 URL 重定向到 HTTPS。我们所要做的就是在 <security:intercept-url/> 上设置 requires-channel="https"标签。

<security:http auto-config="true">
    <security:form-login .../>
    <security:logout .../>

    <security:intercept-url pattern="/reports" access="ROLE_ADMIN" requires-channel="https"/>
    <security:intercept-url pattern="/login" access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https"/>
    <security:intercept-url pattern="/**" access="ROLE_USER" requires-channel="https"/>
</security:http>

使用此配置,当用户点击 http://server/app 时, 它将被重定向到 https://server/app .

有关更多详细信息,请查看 this链接。

关于java - 如何强制我在 Spring 中的所有页面使用 https 协议(protocol),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35586717/

相关文章:

java - 如何使用 lp_solve 和 Java 包装器设置自由变量

java - java中使用JPA(JpaDaoSupport)调用存储过程

带 DLL 的 Spring-boot 可执行 tomcat

java - eclipse 中的文件路径错误? (Java 之春)

java - "to=3573072/3600000"在 java.io.EOFException : HttpConnectionOverHTTP? 异常中意味着什么

java - 什么是 NullPointerException,我该如何解决?

Java继承问题: going beyond the vtable

json - Angular orderBy 对象可能吗?

unit-testing - 超时如何在 karma 中运行的 Angular 测试中工作

javascript - 如何理解AngularJS中指令的scope属性?