我正在使用symfony 2.2.3
和FOSRestBundle
實施Restful
Web服務。創建參數化安靜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"
您是否在app/config/routing.yml中註冊了包路由?另外在終端中輸入php app/console router:debug。它會列出所有可用的路線。 – Onema
我編輯了這個問題,但我不知道如何用'app/console router:debug'來做到這一點 – Hunt