zoukankan      html  css  js  c++  java
  • Spring MVC-从零开始-@RequestMapping 注解method属性

    1、@RequestMapping 处理 HTTP 的各种方法(GET, PUT, POST, DELETE  PATCH)

    package com.jt;
    
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.ResponseBody;
    
    @Controller
    @RequestMapping(value="/FirstControl")
    public class HelloControl {
        @RequestMapping(value="/myget",method=RequestMethod.GET)
        @ResponseBody
        public String get(){
            return "gte";
        }
        
        @RequestMapping(method=RequestMethod.POST)
        @ResponseBody
        public String post(){
            return "post";
        }
        
        @RequestMapping(method=RequestMethod.DELETE)
        @ResponseBody
        public String delete(){
            return "delete"; 
        }
    }

    效果如下:

    2、RequestMapping的简体

    • @GetMapping
    • @PostMapping
    • @PutMapping
    • @DeleteMapping
    • @PatchMapping
  • 相关阅读:
    SQLite3 of python
    爬虫半成品
    python初体验 ——>>> 模拟体育竞技
    文件操作
    numpy 库简单使用
    numpy 与 matplotlib 的应用
    面向对象的详细解读
    使用python进行微信好友分析
    我的第一个爬虫实验
    排球训练营
  • 原文地址:https://www.cnblogs.com/jiangtao1218/p/8586233.html
Copyright © 2011-2022 走看看