douyun1852 2013-09-29 19:59
浏览 67

创建参数化restful webservice时没有路由发现错误

i am using symfony 2.2.3 with FOSRestBundle to implement Restful webservices.

here is my code but when i fire following url i am getting following error

No route found for "GET /business/john"

here is the controller code

use FOS\RestBundle\Controller\Annotations as Rest;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Symfony\Component\Security\Core\Exception\AccessDeniedException;

use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Routing\ClassResourceInterface;

class BusinessController extends Controller {


        public function getBusinessAction($para){


          return new JsonResponse(array('name' => $para));
        } 

}

here is my url

http://localhost/symfony/web/app_dev.php/business/john

here is my route

if i remove the argument from url and from function getBusinessAction then it works but not with arguments/

_business:
    resource: "@HubHomeBundle/Controller/BusinessController.php"    
    type: rest

update

inside app/confing/routing.yml

   hub_home:
    resource: "@HubHomeBundle/Resources/config/routing.yml"
  • 写回答

1条回答 默认 最新

  • dqys98341 2013-10-02 13:10
    关注

    Just to make sure, is this from HubHomeBundle/Resources/config/routing.yml?

    _business:
        resource: "@HubHomeBundle/Controller/BusinessController.php"    
        type: rest
    

    If so try editing it and changing it to:

    _business:
        resource: HubHomeBundle\Controller\BusinessController   
        type: rest
    

    The value of your 'resource' tag should be the fully qualified name of the controller Class, not the path to the file

    评论

报告相同问题?

悬赏问题

  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果