我使用的是Spring框架版本4.3.5.RELEASE . Spring安全版是4.2.2.RELEASE .
我正面临一个与CSRF有关的奇怪问题 . 每当我提交一个表单(来自JSP文件), Sometimes it works fine, the form gets submitted without error but sometimes after submitting the form 时,它会显示 Http Status 405 ? Method not supported . 我也包含了csrf令牌,它们都隐藏在字段中,并将其作为查询字符串附加在表单's action' s标记中 .
这是我的项目中的示例POST表单:
action="http://localhost:8080/update/edit.html?${_csrf.parameterName}=${_csrf.token}">
这是我提交上述表格的控制器:
@RequestMapping(value = "/update/edit.html", method = RequestMethod.POST)
public String saveEdit(ModelMap map, @Valid @ModelAttribute(MODEL_KEY) DealerVisitVO dealerVisitVO, BindingResult result,
@RequestParam(required = false, name="followup") Boolean followup) {
//my codes here
}
The problem is coming random. 它有时有效,有时也无效 . 代码或表单没有变化 . 禁用CSRF不是一种可能的解决方案,因为这是我的客户的一项要求 .
如果有人能够解决,请帮助 .
博主遇到一个随机出现的CSRF相关问题,使用Spring框架4.3.5和Spring Security 4.2.2。在提交包含CSRF令牌的JSP表单时,有时会收到HttpStatus 405错误。问题表现为表单提交有时成功,有时失败,而代码和表单未做改动。禁用CSRF不是解决方案,因为客户有此需求。博主正在寻求解决方案。
574

被折叠的 条评论
为什么被折叠?



