• 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数据就可以

  • 相关阅读:
    vue3+typescript引入外部文件
    vue项目中使用sass
    关于Vue.use()使用详解
    案例:密码框格式提示信息错误
    案例:显示隐藏文本框里面的内容
    案例:循环精灵图案例
    案例:关闭淘宝二维码案例
    案例: 仿京东显示隐藏密码
    案例:根据系统时间显示不同的问候语
    ES6中类和对象的注意问题
  • 原文地址:https://www.cnblogs.com/yaoxublog/p/10918426.html
Copyright © 2020-2023  润新知