2016-02-23 20 views
3

我下载了um应用程序的源代码并部署在Heroku中,尽管我无法运行它。如何在Spring中强制我的所有页面使用https协议

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

Error Screenshot

+2

可能的重复[如何使用Spring Security Java配置将HTTP请求重定向到HTTPS?](http://stackoverflow.com/questions/24650450/how-to-redirect-http-requests-to-https-using- spring-security-java-configuration) – Stilleur

回答

1

web应用程序支持HTTP和HTTPS。如果您想强制所有网址使用HTTPS。你需要做的就是设置require-channel。 Spring Security有一个简单的配置,允许我们将所有基于HTTP的URL重定向到HTTPS。我们所要做的就是在<security:intercept-url/>标签上设置require-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链接。

+0

感谢您的回复,所以我必须将其添加到我的pom.xml文件中? –

+0

不客气。在spring-config.xml中定义它 –

相关问题