这是我的代码:
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。
为什么?
非常感谢您提前
答案 0 :(得分:3)
您需要在响应中设置标题:
$this->response->headers('Content-Type', 'text/xml');