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 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿