【发布时间】:2014-06-26 06:27:18
【问题描述】:
我正在使用 Symfony 2.5。我从控制器返回我的视图模板页面。
但是,当我呈现页面时,它会将原始缓存显示为<body> 标记中的第一部分。
HTTP/1.0 200 OK Cache-Control: no-cache Date: Thu, 26 Jun 2014 06:07:05 GMT []
我用谷歌搜索发现this answer(与我的问题相似)和this answer(大致相同)。
所以我一一尝试了以下所有方法。但没有任何效果。
return $this->render('MyBookBundle:Section:splash.html.php' , $this->data);
和
echo $this->renderView('MyBookBundle:Section:splash.html.php' , $this->data);
return new Response();
和
$displaypage = $this->renderView('MyBookBundle:Section:splash.html.php' , $this->data);
return new Response( $displaypage );
和
$displaypage = $this->render('MyBookBundle:Section:splash.html.php' , $this->data);
return new Response( $displaypage->getContent() );
我的网页处于最简单的阶段。
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
</head>
<body>
<div>Hello World</div>
</body>
</html>
这些方法仍然没有奏效。有人可以指导我正确的方向吗?
【问题讨论】:
-
您的网络服务器是 apache2 吗?如果您查看源代码(不是使用调试器,而是通过进入页面源代码),这些数据是写在页面的最顶部还是真的在
<body>标记之后? -
是的。这是正确的。我使用的是 Apache 2,数据紧跟在
<body>标记之后。