我使用的是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不是一种可能的解决方案,因为这是我的客户的一项要求 .
如果有人能够解决,请帮助 .