zoukankan      html  css  js  c++  java
  • springmvc 后端入口参数接收

    package controller;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestBody;
    import org.springframework.web.bind.annotation.RequestMapping;
    
    import java.util.HashMap;
    import java.util.Map;
    
    @Controller
    @RequestMapping("/enter")
    public class EnterController {
    
        //get请求  无参数
        //http://localhost:8080/springmvc/enter/demo1
        @RequestMapping("/demo1")
        public void demo1(){
            System.out.println("demo1");
            //结果  demo1
        }
    
    
        //get 请求 有参数
        //http://localhost:8080/springmvc/enter/demo2/001
        @RequestMapping("/demo2/{serverCode}")
        public void demo2(@PathVariable String serverCode){
            System.out.println(serverCode);
            //  结果   001  后边参数可以变动,  是按照顺序排列的
        }
    
        //get 请求 有参数
        //http://localhost:8080/springmvc/enter/demo2/001
        @RequestMapping("/demo3/{serverCode}/{pathcode}")
        public void demo3(@PathVariable String serverCode,@PathVariable String pathcode){
            System.out.println(serverCode + " " + pathcode);
            //001 123
            //  结果   001  后边参数可以变动,  是按照顺序排列的
        }
    
    
        //post请求  工具模拟  jmeter
        //http://localhost:8080/springmvc/enter/demo4   post
        //content-Type	application/json
        @RequestMapping("/demo4")
        public void demo4(@RequestBody String requestBody){
    
            System.out.println(requestBody);
            //{"userId":"123456"}
        }
    
    
        //以上为纯后端开发
    
    }
    
    

    返回直接返回string数据就可以

  • 相关阅读:
    博客园背景页面动态特效
    windows7 VirtualBox 安装docker异常:looks like something went wrong in step ‘looking for vboxmanage.exe’
    VUE 封装axios 接口
    实时显示系统当前时间时间
    Git 命令执行
    从模型训练中认知拟合现象
    ModernRNN
    Fundamentals of Recurrent Neural Network
    Language Model & Data Sampling
    Text Preprocessing
  • 原文地址:https://www.cnblogs.com/yaoxublog/p/10918426.html
Copyright © 2011-2022 走看看