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
  • 相关阅读:
    登录权限
    ajax搜索分页
    dos命令
    tp5单删
    MVC简易封装
    linux环境安装swoole
    nginx环境安装laravel404问题
    ABZ职业规划
    Yii安装curl
    SKU的概念和理解
  • 原文地址:https://www.cnblogs.com/jiangtao1218/p/8586233.html
Copyright © 2011-2022 走看看