如果使用外部URL,则不在JSF中呈现IFrame

Mar*_*oky 0 iframe jsf

当我在引用外部网页的JSF页面中使用IFrame时.页面未呈现.

JSF代码:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">

<f:loadBundle basename="resources.application" var="msg" />
<h:head>
<title>E-Payment Gateway</title>
<link type="text/css" rel="stylesheet"
    href="${facesContext.externalContext.requestContextPath}/resources/css/main_style.css" />

</h:head>

<h:body>
<f:view>
     <div style="height: 200px;">

    </div> 
    <div class="centercol" style="margin: auto;position: relative">
        <iframe
            src="http://google.com">
        </iframe>
    </div>
</f:view>
</h:body>
Run Code Online (Sandbox Code Playgroud)

HTML结果

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>

<title>E-Payment Gateway</title>

<link type="text/css" rel="stylesheet" href="/EPG_WEB_CUST/resources/css/main_style.css" /></head><body>
     <div style="height: 200px;">

    </div> 
    <div class="centercol" style="margin: auto;position: relative">
        <iframe src="http://google.com">
 #document<html><head></head><body></body></html></iframe>
    </div></body></html>
Run Code Online (Sandbox Code Playgroud)

我不知道是什么原因引起了这个问题,它总是显示空的反叛HTML

Adh*_*der 7

问题不在于JSF或防火墙.

您尝试http://google.com在不同域中的iFrame中使用.这是一种潜在的安全威胁,称为跨站点脚本(XSS).您的问题的答案在于谷歌的http标头.

为了避免XSS攻击,谷歌添加了以下标题.

X-FRAME-OPTIONS
X-XSS-PROTECTION
Run Code Online (Sandbox Code Playgroud)

换句话说,由于上述标题,您无法在不同域中的iFrame中访问它们,请在此处了解有关XSS的更多信息以及此处有关同源策略的信息

在此输入图像描述

希望这能解决你的问题.