问题
I'm using Java 7, Spring-Boot 1.1.7 and an ambeded Tomcat 7.
In the past, when I used a stand alone Tomcat, I used to add an http connector, that will redirect the requests to the HTTPS port :
<Connector port="8080" enableLookups="false"
redirectPort="8443" />
How can I do it when I'm using an embeded Tomcat (and I dont have a server.xml file) ?
回答1:
You can add a Connector
or configure the existing one with its Java API (e.g. see http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-enable-multiple-connectors-in-tomcat). The Connector
has a setRedirectPort()
(it's mapped directly by the XML <Connector/>
element).
来源:https://stackoverflow.com/questions/26438143/spring-boot-embeded-tomcat-http-to-https-redirect