gpt4 book ai didi

jquery - Dispatcher.xml 中已弃用 DefaultAnnotationHandlerMapping

转载 作者:行者123 更新时间:2023-12-01 07:09:12 25 4
gpt4 key购买 nike

org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter 已弃用并且mvc-dispatcher.xml 中的 org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping 错误。为什么会这样?请帮助我?

代码如下

<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="saveGeoJSON.html">HspatialController</prop>
</props>
</property>
</bean>

DefaultAnnotationHandlerMapping 和 AnnotationMethodHandlerAdapter 带有删除线

最佳答案

如果您使用的是 Spring 3.1 及更高版本,则应将这些类替换为 RequestMappingHandlerMappingRequestMappingHandlerAdapter

如果您检查 Spring 3.1 reference documentation ,您会明白为什么这些类已被弃用:

Spring 3.1 introduces a new set of support classes for processing requests with annotated controllers:

RequestMappingHandlerMapping

RequestMappingHandlerAdapter

ExceptionHandlerExceptionResolver

These classes are a replacement for the existing:

DefaultAnnotationHandlerMapping

AnnotationMethodHandlerAdapter

AnnotationMethodHandlerExceptionResolver

The new classes were developed in response to many requests to make annotation controller support classes more customizable and open for extension. Whereas previously you could configure a custom annotated controller method argument resolver, with the new support classes you can customize the processing for any supported method argument or return value type.

A second notable difference is the introduction of a HandlerMethod abstraction to represent an @RequestMapping method. This abstraction is used throughout by the new support classes as the handler instance. For example a HandlerInterceptor can cast the handler from Object to HandlerMethod and get access to the target controller method, its annotations, etc.

The new classes are enabled by default by the MVC namespace and by Java-based configuration via @EnableWebMvc. The existing classes will continue to be available but use of the new classes is recommended going forward.

关于jquery - Dispatcher.xml 中已弃用 DefaultAnnotationHandlerMapping,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31902767/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com