编辑conf/web.xml文件


Tomcat配置http自动中转https - 图1
在web.xml末尾加上如下配置:

  1. <security-constraint>
  2. <web-resource-collection >
  3. <web-resource-name >SSL</web-resource-name>
  4. <url-pattern>/*</url-pattern>
  5. </web-resource-collection>
  6. <user-data-constraint>
  7. <transport-guarantee>CONFIDENTIAL</transport-guarantee>
  8. </user-data-constraint>
  9. </security-constraint>

重启Tomcat服务