如何通过 https 启动 java servlet?

2024-01-04

我正在尝试在 eclipse 中的 tomcat 上运行 servlet。当我在服务器上运行时,servlet 会运行并为我提供如下链接:

“http://localhost:8443/AuthServer/服务器”

我已将 Tomcat 服务器配置为 SSL,如下所示:

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" keystoreFile="C:\Users\owner\.keystore" keystorePass="sheetalkshirsagar">

当我在服务器上运行 servlet 时,它仍然使用 http。 我希望 servlet 的链接为“https://...”而不是“http://..”。你是怎样做的?


如果您想在向该 servlet 发送请求时确保使用 https 协议,则需要更改WEB-INF/web.xml文件在您的网络应用程序中。 在您的情况下添加此配置参数:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>AuthServer</web-resource-name>
        <url-pattern>/Server</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何通过 https 启动 java servlet? 的相关文章

随机推荐