我正在使用symfony 2.2.3
与FOSRestBundle
一起实施Restful
网络服务。
这是我的代码,但是当我触发以下网址时,我收到了以下错误
No route found for "GET /business/john"
这是控制器代码
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));
}
}
这是我的网址
http://localhost/symfony/web/app_dev.php/business/john
这是我的路线
如果我从url和函数getBusinessAction
中删除参数,那么它可以工作,但不能使用参数/
_business:
resource: "@HubHomeBundle/Controller/BusinessController.php"
type: rest
更新
在app/confing/routing.yml
hub_home:
resource: "@HubHomeBundle/Resources/config/routing.yml"
答案 0 :(得分:1)
只是为了确保,这是来自HubHomeBundle / Resources / config / routing.yml?
_business:
resource: "@HubHomeBundle/Controller/BusinessController.php"
type: rest
如果有,请尝试编辑并将其更改为:
_business:
resource: HubHomeBundle\Controller\BusinessController
type: rest
“资源”标记的值应该是控制器类的完全限定名称,而不是文件的路径