我无法收到请求POST这个我的代码
public function inscriptionAction() {
$session = $this->getRequest()->getSession();
$request = Request::createFromGlobals();
$myCat = new \ stdClass;
$privatekey=$request->request->get('privatekey');
$key=$request->request->get('key');
if ($key== 'NULL' or $privatekey == NULL ) {
return $this->render('GestionsFilmeBundle:public:identification.html.twig', array(
'message' => 'Parametres non fournies-----',));
}
}
但privatekey和key为null
答案 0 :(得分:0)
如果您使用的是Symfony Framework,则无需构建Request
对象,只需将其自动注入到您的操作中,然后就可以从那里使用它。
public function inscriptionAction(Request $request) {
$privateKey = $request->request->get('privatekey');
$key = $request->request->get('key');
if (null === $key || null === $privateKey) {
return $this->render(
'GestionsFilmeBundle:public:identification.html.twig',
array(
'message' => 'Parametres non fournies-----',
)
);
}
}