【轉】tornado出現’_xsrf’ argument missing from POST問題解決


看到的地址:http://www.codeif.com/post/914/

tornado出現’_xsrf’ argument missing from POST問題解決

在使用tornado框架進行web開發的時候,post提交數據出現 '_xsrf' argument missing from POST錯誤,頁面提示403: Forbidden

出現原因:
在我們的setting中設置了:

xsrf_cookies=True

解決方案一:

xsrf_cookies=True

改為

xsrf_cookies=False

解決方案二: 提交的表單中加上: _xsrf ,可以使用內置函數xsrf_form_html() 來幫我們完成

如下:

<form action="/new_message" method="post">

  <input type="text" name="message"/>
  <input type="submit" value="Post"/>
</form>

參考文章:
http://sebug.net/paper/books/tornado/
http://stackoverflow.com/questions/12890105/tornado-xsrf-argument-missing-from-post


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM