(类型转化的错误)java.lang.IllegalStateException:no matching editors or conversion strategy found

本文阅读 2 分钟
首页 代码,Java 正文

        今天小编在写SSM整合的时候,突然在项目启动的时候就报了下面这个错误。

Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘org.springframework.web.servlet.handler.MappedInterceptor#2’: Unsatisfied dependency expressed through constructor parameter 2: Could not convert argument value of type [cn.beyondFlateForm.interceptor.SysInterceptor] to required type [org.springframework.web.context.request.WebRequestInterceptor]: Failed to convert value of type ‘cn.beyondFlateForm.interceptor.SysInterceptor’ to required type ‘org.springframework.web.context.request.WebRequestInterceptor’; nested exception is java.lang.IllegalStateException: Cannot convert value of type ‘cn.beyondFlateForm.interceptor.SysInterceptor’ to required type ‘org.springframework.web.context.request.WebRequestInterceptor’: no matching editors or conversion strategy found

        之前小编在做项目的时候也没有报这个错误,今天突然就报了这个错误,很神奇,而且报错信息还那么长,真是看了一遍又一遍,害。看到最后两句英文报错信息,大概知道了是类型转换错误。然后我就找“springmvc-servlet”的配置文件,里面有一个拦截器的配置,如下:

<mvc:interceptors>
        <mvc:interceptor>
            <mvc:mapping path="/manager/backend/**"/>
            <mvc:mapping path="/dev/flatform/**"/>
            <bean class="cn.beyondFlateForm.interceptor.SysInterceptor"/>
        </mvc:interceptor>

    </mvc:interceptors>

接着找到SysInterceptor这个方法,点进去,看到代码才知道错在哪了

public class SysInterceptor { 
}

        这个类是要继承一个父类HandlerInterceptorAdapter的,怪不得会出现类型转换错误呢。以后啊,敲代码的时候一定要认真仔细,千万不要因为一个小细节而浪费几十分钟的时间找一个不该出的bug。

本文为互联网自动采集或经作者授权后发布,本文观点不代表立场,若侵权下架请联系我们删帖处理!文章出自:https://blog.csdn.net/qq_46540738/article/details/116663276
-- 展开阅读全文 --
安全面试之XSS(跨站脚本攻击)
« 上一篇 07-24

发表评论

成为第一个评论的人

热门文章

标签TAG

最近回复