Tomcat配置如下:
1.server.xml设置:
<Connectorport=”80″protocol=”HTTP/1.1″connectionTimeout=”20000″redirectPort=”443″/>
2.web.xml设置
<!–添加到web.xml最后面–>
<security-constraint> <web-resource-collection> <web-resource-name>SSL</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint>
3.重启Tomcat测试
http://localhost自动跳转https://localhost.
让技术之花,在头条盛开……
也可以直接查看到偶的头条文章:Tomcat设置http自动跳转https