spring mvc HandlerMapper和HandlerAdapter

在开发web项目的时候,我们需要HandlerMapper和HandlerAdapter,不同的mapper规定了我们在查找handler时的行为,可以根据bean的name寻找我们的handler等,不同adapter规定我们怎样定义handle,可以实现controller等。我们可以在配置文件中的配置

非注解的配置

org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
 
  

注解的配置

在spring3.1之前使用org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping注解映射器。

在spring3.1之后使用org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping注解映射器。

在spring3.1之前使用org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter注解适配器。

在spring3.1之后使用org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter注解适配器。

推荐一下方式的注解配置

 


 
  
 
  

当然我们也可以不用配置或者是配置多个都行mapper和adapter,在不配置的情况下会使用DispatcherSerlvet.properties属性文件下的默认配置

你可能感兴趣的:(spring)