spring 安全 xml 中的自定义异常映射
custom exception mapping in spring security xml
我在 spring security.xml
中给出以下片段
<!-- Exception Mapping configuration -->
<bean id="securityExceptionTranslationHandler"
class="com.abc.xyz.ExceptionMappingFailureHandler" >
<property name="exceptionMappings">
<props>
<prop key="org.springframework.security.authentication.CredentialsExpiredException">/408</prop>
</props>
</property>
</bean>
我在启动 tomcat 时收到错误提示:
com.abc.xyz.ExceptionMappingFailureHandler class 的 属性 exceptionMappings 无效:Bean 属性 exceptionMappings 不可写或具有无效的 setter 方法。
com.abc.xyz.ExceptionMappingFailureHandler class 的内容应该是什么?
任何帮助将不胜感激!
您的 class 应该看起来像这样才能工作:
package com.abc.xyz;
public class ExceptionMappingFailureHandler {
public void setExceptionMappings(Map mappings) {
...
}
}
重要的是有一个 setter 有那个名字,它 returns 无效,并且接受一个 Map 类型的参数。
我在 spring security.xml
中给出以下片段<!-- Exception Mapping configuration -->
<bean id="securityExceptionTranslationHandler"
class="com.abc.xyz.ExceptionMappingFailureHandler" >
<property name="exceptionMappings">
<props>
<prop key="org.springframework.security.authentication.CredentialsExpiredException">/408</prop>
</props>
</property>
</bean>
我在启动 tomcat 时收到错误提示: com.abc.xyz.ExceptionMappingFailureHandler class 的 属性 exceptionMappings 无效:Bean 属性 exceptionMappings 不可写或具有无效的 setter 方法。
com.abc.xyz.ExceptionMappingFailureHandler class 的内容应该是什么? 任何帮助将不胜感激!
您的 class 应该看起来像这样才能工作:
package com.abc.xyz;
public class ExceptionMappingFailureHandler {
public void setExceptionMappings(Map mappings) {
...
}
}
重要的是有一个 setter 有那个名字,它 returns 无效,并且接受一个 Map 类型的参数。