@Controller处理由DispatcherServlet 分发的请求,用于类上把用户请求的数据经过业务处理层处理之后封装成一个Model再把该Model 返回给对应的View 进行展示@RequestMapping处理请求地址映射的注解,可用于类或方法属性value: 指定请求的实际地址,指定的地址可以是URI Template 模式method: 指定请求的method类型, GET、POST、PUT、DELETE...consumes: 指定处理请求的提交内容类型(Content-Type),例如application/json, text/htmlproduces: 指定返回的内容类型,仅当request请求头中的(Accept)类型中包含该指定类型才返回params: 指定request中必须包含某些参数值是,才让该方法处理headers: 指定request中必须包含某些指定的header值,才能让该方法处理请求@Resource、@Autowired在bean的注入时使用写在字段和setter方法上。两者如果都写在字段上,那么就不需要再写setter方法@PathVariable用于将请求URL中的模板变量映射到功能处理方法的参数上,即取出uri模板中的变量作为参数@requestParam主要用于在SpringMVC后台控制层获取参数,类似一种是request.getParameter("name")@ResponseBody将Controller的方法返回的对象,通过适当的HttpMessageConverter转换为指定格式@Component通用注解(可代替@Repository @Service @Controller)@Repository用于注解dao层,在daoImpl类上面注解@ModelAttribute、@SessionAttributes传递和保存数据,在不同的模型(model)和控制器之间共享数据@PathVariable、@RequestParam@PathVariable获取请求路径上的变量值@RequestParam用来获得静态的URL请求入参 spring注解时action里用到@RequestHeader、@CookieValue@RequestHeader可以把Request请求header部分的值绑定到方法的参数上。@CookieValue可以把Request header中关于cookie的值绑定到方法的参数上@RequestParam, @RequestBody@RequestParam用来处理Content-Type: 为 application/x-www-form-urlencoded编码的内容,提交方式GET、POST@RequestBody常用来处理Content-Type: 不是application/x-www-form-urlencoded编码的内容,例如application/json,application/xml等 Last modification:January 21st, 2021 at 09:02 pm © 允许规范转载