Respond as XML not working since cakePHP 3.1

前端 未结 1 1808
慢半拍i
慢半拍i 2020-12-21 20:27

I need to render an XML+XSL template in my application, and it used to work with cakePHP 3.0. I have made the switch to 3.1 recently and it has stopped working. The problem

相关标签:
1条回答
  • 2020-12-21 20:59

    Try add: $this->response->header(['Content-type' => 'application/xml']);

    I had the same error but my output was pdf

    working 3.0.14 using this code:

    $this->RequestHandler->respondAs("pdf");
    $this->layout = 'pdf/default';
    $this->view = 'pdf/report1_pdf';
    

    for 3.1.x (this works if u save the file and open later, if you try to open it directly on browser its print the plain file content as a txt/html):

    $this->viewBuilder()->layout('pdf/default');
    $this->viewBuilder()->template('pdf/report1_pdf');
    $this->RequestHandler->respondAs('pdf');
    $this->response->header(['Content-type' => 'application/pdf']);
    
    0 讨论(0)
提交回复
热议问题