我正在使用symfony 2.2.3
withFOSRestBundle
来实现Restful
web 服务。
这是我的代码,但是当我触发以下网址时,我收到以下错误
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"