【Https異常】This request has been blocked; the content must be served over HTTPS


一、問題出現場景

項目從http升級到https后,jsp頁面存在發送http請求的情況下就會出現該異常。因為HTTPS 是 HTTP over Secure Socket Layer,以安全為目標的 HTTP 通道,所以在 HTTPS 承載的頁面上不允許出現 http 請求。

 

二、解決辦法

在jsp頁面中,添加下面的meta頭就可以了

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
</head>
<body>
<script type="text/javascript">
</script>
</body>
</html>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM