我有一个简单的crud控制器
<?php
namespace MyBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use MyBundle\Entity\MyEntity;
use MyBundle\Form\MyEntityType;
/**
* PsaEventualidadContrato controller.
*
* @Route("/my")
*/
class MyController extends Controller
{
//...
/**
* Displays a form to create a new MyEntity entity.
*
* @Route("/new.{_format}", name="my_new", defaults={"_format"="json"})
* @Method("GET")
* @Template()
*/
public function newAction()
{
$entity = new MyEntity();
$form = $this->createCreateForm($entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
}
//...
}当我去http://myhost/app_dev.php/my/new.json in dev.log时,我可以看到
[2013-09-28 11:29:13] request.INFO: Matched route "eventualidad_new" (parameters: "_format": "json", "_controller": "MyBundle\Controller\MyController::newAction", "_route": "my_new") [] []但是浏览器呈现html模板。为什么会发生这种事?
我用的是Symfony v2.3.4和v2.3.5
发布于 2013-09-28 17:02:45
包FOS\RestBundle\FOSRestBundle正在创建冲突,当我从AppKernel.php中移除一切正常工作时
https://stackoverflow.com/questions/19069194
复制相似问题