https://blog.csdn.net/sanshipianyezi/article/details/72737391 参考该作者,补充你两点
1. 关于端口号的修改
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="/user/software/tomcat-8.0.28-api/.keystore" keystorePass="passWord"/>
这边修改为443后,http的端口号8080或者80的配置有一个端口号要修改
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" /> <!-- 注意 -->
还有一处
<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />
2. 配置tomcat使http自动跳转至https,配置conf里的web.xml文件
<security-constraint>
<!-- Authorization setting for SSL -->
<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
测试访问 会自动跳转至https说明配置成功了
再次感谢原作者。