4

当我将数据发布到服务器重定向时:

$view = $this->routeRedirectView('get_config', array('id' => $config->getId()));
return $this->handleView($view);

这是请求被重定向到的操作代码:

/** 
 * @View()
 */
public function getConfigAction($id)
{   
    $config = $this->getConfigById($id);
    return array('configs' => array($config));
}

创建工作正常。但是重定向不起作用,因为我希望它起作用。当我执行以下命令时

curl -v -H "Accept: application/xml" -H "Content-type: application/json" -X POST \
-d '{"config": {"name": "TEST1"}}' http://localhost:8888/app_dev.php/configs

输出是:

< HTTP/1.0 201 Created
< Date: Wed, 19 Dec 2012 14:13:17 GMT
< location: http://localhost:8888/app_dev.php/configs/12

我无法管理包含新创建实体的响应。这是所需的输出:

< HTTP/1.0 201 Created
< Date: Wed, 19 Dec 2012 14:13:17 GMT
< location: http://localhost:8888/app_dev.php/configs/12
<?xml version="1.0" encoding="UTF-8"?>
<result>
  <entry>
    <entry>
      <id>12</id>
      <name><![CDATA[TEST1]]></name>
    </entry>
  </entry>
</result>
4

0 回答 0