所以我有这个控制器
/**
* @Route("/submit", name="submit")
*/
public function submitAction(Request $request) {
var_dump($request->getMethod());
}
现在,如果我使用
在我的树枝模板中创建表单<form action="{{ path('submit') }}" method="post">
<input type="text" name="text">
<button type="submit">Submit</button>
</form>
getMethod
返回POST
但是如果我做同样的事情,但在动作中使用完整的URL,就像这样
<form action="http://domain.my/submit" method="post">
getMethod
会返回GET。
我该如何解决这个问题?
答案 0 :(得分:1)
非常简单
https://github.com/nelmio/NelmioCorsBundle
nelmio_cors:
paths:
'^/xml/':
allow_origin: ['*']
allow_methods: ['POST']