Jsp Tomcat重定向到SSL认证的站点

Jsp Tomcat重定向到SSL认证的站点,jsp,tomcat,redirect,server.xml,Jsp,Tomcat,Redirect,Server.xml,我想强制将站点重定向到SSL认证的站点。我已经在我的server.xmltomcat配置中添加了这些配置 <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" enableLookups="false" redirectPort="8443" /> <Connector port="8443" protocol="HTTP/

我想强制将站点重定向到SSL认证的站点。我已经在我的
server.xml
tomcat配置中添加了这些配置

<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           enableLookups="false"
           redirectPort="8443" />

<Connector port="8443" protocol="HTTP/1.1"
    SSLEnabled="true" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25"
    maxSpareThreads="75" enableLookups="false"
    disableUploadTimeout="true" acceptCount="100"
    scheme="https" secure="true"
    sslProtocol="TLS" keystoreFile="conf/{keystoreName}.jks"
    keystorePass="{KeyStorePass}" />

但我最终在非SSL和SSL认证站点中查看了我的站点。如何限制和重定向非SSL认证到SSL认证

编辑:

下面是my web.xml的一部分:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>HTTPSOnly</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>HTTPSOrHTTP</web-resource-name>
        <url-pattern>*.ico</url-pattern>
        <url-pattern>/img/*</url-pattern>
        <url-pattern>/css/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>

HTTPSOnly
/*
保密的
HTTPSOrHTTP
*.ico
/img/*
/css/*
没有一个

您必须在web.xml中对此进行配置。请看。我已经用它配置了我的web.xml,只有图像和JavaScript可以通过http和https访问。请检查我编辑的问题。注意,这可能会导致问题。如果从安全资源(如HTML中的图像)访问不安全资源,浏览器可能会发出警告。尽量避免这样。你试过没有第二个限制。