【问题标题】:CSRF token is null on file upload- spring mvcCSRF令牌在文件上传时为空-spring mvc
【发布时间】:2015-03-16 19:06:35
【问题描述】:

我正在上传一个文件。该jsp具有以下内容。

 <form id="uploadRepoData" enctype="multipart/form-data">
  <input style="width: 250px" type="file" name="loadfile" class="loadInputDisplay"/> 

单击提交按钮时,csrf 令牌会附加到表单并完成发布请求。 但是,该请求似乎有一个空 csrf 令牌,因此该请求被认为是一个无效请求,并且 它失败了。

我不知道如何解决这个问题。

【问题讨论】:

  • 能分享一下spring security的配置吗?

标签: spring model-view-controller csrf csrf-protection


【解决方案1】:

通过将 csrf 令牌作为查询参数附加到修复它的操作

【讨论】:

  • 你能澄清一下你是怎么做到的吗?
【解决方案2】:

在表单操作中添加 csfr......

<s:form  action="${pageContext.request.contextPath}/admin/marketinfo/bulkupload?${_csrf.parameterName}=${_csrf.token}" 
   enctype="multipart/form-data" modelAttribute="upload" method="POST" 
   class="form-horizontal" role="form">

【讨论】:

    猜你喜欢
    • 2015-09-26
    • 2014-02-27
    • 2012-03-06
    • 2020-10-18
    • 2015-01-31
    • 2015-11-03
    • 2017-03-20
    • 2015-04-08
    • 2019-11-18
    相关资源
    最近更新 更多