Bean命名为requestDataValueProcessor'必须是[org.springframework.web.servlet.support.RequestDataValueProcessor]类型

时间:2016-05-31 15:12:12

标签: spring-mvc

Servlet.service() for servlet [springmvc] in context with path [] 
threw exception [Request processing failed; nested exception is 
org.springframework.beans.factory.BeanNotOfRequiredTypeExcepti
on: Bean named 'requestDataValueProcessor' must be of type [org.springframework.web.servlet.support.RequestDataValueProcessor], 
but was actually of type [org.springframework.security.web.servlet.suppo
rt.csrf.CsrfRequestDataValueProcessor]] 
with root cause
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 
'requestDataValueProcessor' must be of type 
[org.springframework.web.servlet.support.RequestDataValueProcessor], but was actually of type 
[org.springframework.security.web.servlet.support.csrf.CsrfRequestDataValueProcessor]

我收到此错误。

1 个答案:

答案 0 :(得分:3)

从Spring Security 3.x升级到4.x时会导致此问题。在Spring Security 4中,CSRF现在默认启用。

将以下内容添加到登录页面

<csrf disabled="true"/>

Spring Security 3到4迁移指南http://docs.spring.io/spring-security/site/migrate/current/3-to-4/html5/migrate-3-to-4-xml.html#m3to4-xmlnamespace-csrf