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

1、問題出現場景javascript

項目從http升級到https後,jsp頁面存在發送http請求的狀況下就會出現該異常。由於HTTPS 是 HTTP over Secure Socket Layer,以安全爲目標的 HTTP 通道,因此在 HTTPS 承載的頁面上不容許出現 http 請求。html

 

2、解決辦法java

在jsp頁面中,添加下面的meta頭就能夠了安全

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

<%@ 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>
相關文章
相關標籤/搜索