我最近将Symfony项目部署到生产环境中。 除了.getJSON jquery函数之外,所有内容都在加载。 这会返回404错误。现在奇怪的是它适用于当地。
这是代码。
Jquery的:
$.getJSON('/ClientThisYear', function(response) {
路由:
app:
resource: "@AppBundle/Controller"
type: annotation
的appbundle /控制器:
/**
* @Route("/ClientThisYear")
*/
public function ClientThisYear()
{
$em = $this->getDoctrine()->getManager();
$ClientStats = $em->getRepository('ClientBundle:Client')
->ClientStats();
$ClientArray = array();
foreach($ClientStats[0] as $Arr)
{
$ClientArray[] = $Arr;
}
$Return = json_encode($ClientArray);
return new Response($Return,200,array('Content-Type'=>'application/json'));
}
所以它工作了一段时间,但一段时间后它开始返回404错误。
我尝试的是:
错误日志:
[2015-12-30 14:50:43] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /ClientThisYear" (from "http://example.nl/web/admin")" at /home/**/**/var/cache/prod/classes.php line 2377 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /ClientThisYear\" (from \"http://example.nl/web/admin\") at /home/**/**/var/cache/prod/classes.php:2377, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): at /home/**/**/var/cache/prod/appProdUrlMatcher.php:255)"} []
有人可以帮我解决这个问题吗