【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>
相关文章
相关标签/搜索