2012-02-06 76 views
2

我想創建一個使用HTTPS連接的示例。我已經按照Tomcat 6.0文檔中給出的步驟成功配置了自定義證書。 A https://localhost:8443/成功打開Tomcat索引頁面。重定向到HTTPS servlets

我無法配置頁面/ servlet以HTTPS打開。請有人建議我配置一個Web應用程序自動重定向到HTTPS連接的步驟。

回答

1

對傳輸保證爲CONFIDENTIAL的URL使用HTTP(非安全)的請求將自動使用HTTPS重定向到相同的URL。

以下添加到你的web.xml

<security-constraint> 
    <web-resource-collection> 
     <url-pattern>/*</url-pattern> 
    </web-resource-collection> 
    <user-data-constraint> 
     <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
</security-constraint> 
+0

HI拉梅什,感謝您的答覆。但是我已經在web.xml中配置了上面的代碼。我在Eclipse中遇到問題。我的代碼在eclipse外運行良好,但是當我嘗試在Eclipse中運行它時,出現頁面無法加載錯誤。請指教。 – 2012-02-06 12:04:02