我在将 Kohana 3 中的内容类型更改为 XML 时遇到一些问题
这是我的代码:
class Controller_Call extends Controller {
public $template = 'tpl/default';
public function before() {
parent::before();
$this->request->headers('Content-Type', 'text/xml');
$this->template = View::factory($this->template);
}
public function action_index() {
$this->template->response = '<say>Hey! How are you budy!</say>';
}
public function after() {
$this->request->headers('Content-Type', 'text/xml');
$this->response->body( $this->template );
parent::after();
$this->request->headers('Content-Type', 'text/xml');
}
}
当我在 Firefox 中加载页面并查看 Content-Type 时,我得到 text/html。
这是为什么?
预先非常感谢
Here is my code:
class Controller_Call extends Controller {
public $template = 'tpl/default';
public function before() {
parent::before();
$this->request->headers('Content-Type', 'text/xml');
$this->template = View::factory($this->template);
}
public function action_index() {
$this->template->response = '<say>Hey! How are you budy!</say>';
}
public function after() {
$this->request->headers('Content-Type', 'text/xml');
$this->response->body( $this->template );
parent::after();
$this->request->headers('Content-Type', 'text/xml');
}
}
When I load the page in firefox and I look at the Content-Type, I get text/html.
Why is that?
Thank you very much in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在响应上设置标头:
You need to set the headers on the response: