tomcat里设置安全访问-tomcat里设置http到https。

来源:互联网 发布:噪声计算软件 编辑:程序博客网 时间:2024/05/22 03:50

web.xml里加入

        <security-constraint>
                <web-resource-collection>
                        <web-resource-name>Protected Context</web-resource-name>
                        <url-pattern>/*</url-pattern>
                        <http-method>TRACE</http-method>
                        <http-method>GET</http-method>
                        <http-method>POST</http-method>
                </web-resource-collection>
                <user-data-constraint>
                        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
                </user-data-constraint>
        </security-constraint>

 server.xml里加入

       <Connector 
                port="443"
                maxHttpHeaderSize="8192"
                maxThreads="1000"
                minSpareThreads="50"
                maxSpareThreads="70"
                enableLookups="true"
                disableUploadTimeout="true"
                acceptCount="100"
                scheme="https"
                secure="true"
                clientAuth="false"
                sslProtocol="TLS"
                keystoreFile="*.keystore"
                keystorePass="***"/>
  由https到http,正好相反。