zoukankan      html  css  js  c++  java
  • SpringMVC

    SpringMVC中的注解使用

    @Controller

    • Spring MVC 中使用 org.springframework.stereotype.Controller 注解类型声明某类的实例是一个控制器
    • 在mvc配置文件中需要配置<context:component-scan base-package="Controller类所在包"/>扫描加有注解的Controller控制器就是不用手动将Controller一个一个注入Spring容器中
    • @Controller等价于@Controller(value="@Controller")

    @RequestMapping

    • Spring MVC 中使用org.springframework.web.bind.annotation.RequestMapping,在基于注解的控制器类中可以为每个请求编写对应的处理方法
    • @RequestMapping("save")等价于@RequestMapping(value = "save")等价于@RequestMapping(path = "save")
    • 注解的 value 属性将请求 URI 映射到方法,value 属性是 RequestMapping 注解的默认属性,如果只有一个 value 属性,则可以省略该属性

    mvc的注解的驱动

    • 在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注解适配器。

    • <mvc:annotation-driven/>就代表了开启了注解映射器与注解适配器

    不经风雨,怎见彩虹?
  • 相关阅读:
    visual studio 2013 中配置OpenCV2.4.13 姿势
    全栈技能图谱
    Lua 基础
    Lua手动编译姿势
    字符串专题:几种奇怪的算法
    字符串专题:KMP POJ 3561
    字符串专题:后缀数组
    字符串专题:map POJ 1002
    2015安徽省赛 G.你来擒孟获
    求方程解问题
  • 原文地址:https://www.cnblogs.com/MLYR/p/14486379.html
Copyright © 2011-2022 走看看