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

First, the problem scenario

After the project upgrading from http to https, jsp page will appear that there is an exception in the case send http request. Because HTTPS is HTTP over Secure Socket Layer, a secure HTTP channel targeting, so there does not allow http requests on a page hosted HTTPS.

 

Second, the solution

In the jsp page, add the following meta head on it

<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>

 

Guess you like

Origin www.cnblogs.com/756623607-zhang/p/11790283.html