zoukankan      html  css  js  c++  java
  • springboot-springmvc-requestParam

    springmvc请求方式

    1、直接写在形参中:基本类型

    @RequestMapping("/testRequestParam1")
    public ModelAndView testRequestParam1(String name) {
    	ModelAndView mv = new ModelAndView();
    	System.out.println(name);
    	mv.setViewName("helloworld");
    	return mv;
    }
    

    2、直接写在形参中:pojo

    /**
     * 页面请求实例:
     * <form action="http://localhost:8080/hello/testRequestParam4" method="post">
     * <input type="text" name="id"/> <input type="text" name="name"/>
     * <input type="submit" value="提交"/> </form>
     */
    @RequestMapping("/testRequestParam4")
    public ModelAndView testRequestParam4(T1 t) {
    	System.out.println(t.getId());
    	ModelAndView mv = new ModelAndView();
    	mv.setViewName("helloworld");
    	return mv;
    }
    

    3、通过@RequestParam写在形参中

    @RequestMapping("/testRequestParam2")
    public ModelAndView testRequestParam2(@RequestParam(value = "id") Integer id) {
    	ModelAndView mv = new ModelAndView();
    	System.out.println(id);
    	mv.setViewName("helloworld");
    	return mv;
    }
    

    4、通过@PathVariable写在形参中

    @RequestMapping("/testRequestParam3/{id}")
    public ModelAndView testRequestParam3(@PathVariable("id") Integer id) {
    	ModelAndView mv = new ModelAndView();
    	System.out.println(id);
    	mv.setViewName("helloworld");
    	return mv;
    }
    

      

  • 相关阅读:
    引爆点--产品方法论
    智能的差旅预订 竞品分析
    差旅管理
    运营中的用户心理学
    鸡汤
    励志的鸡汤
    cmder安装
    jQuery height() innerHeight() outerHight() width() innerWidth() outerWidth()源码解读
    css未知宽度水平居中整理
    css水平垂直居中块整理
  • 原文地址:https://www.cnblogs.com/lichangyunnianxue/p/9777325.html
Copyright © 2011-2022 走看看