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;
}

  

springboot-springmvc-requestParam的更多相关文章

  1. springboot+springmvc+mybatis项目整合

    介绍: 上篇给大家介绍了ssm多模块项目的搭建,在搭建过程中spring整合springmvc和mybatis时会有很多的东西需要我们进行配置,这样不仅浪费了时间,也比较容易出错,由于这样问题的产生, ...

  2. SpringBoot+SpringMVC+MyBatis快速整合搭建

    作为开发人员,大家都知道,SpringBoot是基于Spring4.0设计的,不仅继承了Spring框架原有的优秀特性,而且还通过简化配置来进一步简化了Spring应用的整个搭建和开发过程.另外Spr ...

  3. springboot+springmvc拦截器做登录拦截

    springboot+springmvc拦截器做登录拦截 LoginInterceptor 实现 HandlerInterceptor 接口,自定义拦截器处理方法 LoginConfiguration ...

  4. SpringBoot/SpringMVC文件下载方式

    本篇文章引用外网博客代码,共描述SpringMVC下三种文件下载方式,本人测试在SpringBoot(2.0以上版本)正常使用. 引用博客,强烈推荐https://www.boraji.com. pa ...

  5. SpringMvc @RequestParam 使用推荐使用包装类型代替包装类型

    SpringMvc 中@RequestParam注解使用 建议使用包装类型来代替基本数据类型 public String form2(@RequestParam(name="age" ...

  6. springboot springmvc 支持 https

    Spring Mvc和Spring Boot配置Tomcat支持Https 背景 最近在项目开发中需要让自己的后端Restful接口支持https,在参考了很多前辈们的博客后总结了一些. Spring ...

  7. springMVC --@RequestParam注解(后台控制器获取參数)

    在SpringMVC后台控制层获取參数的方式主要有两种,一种是request.getParameter("name"),第二种是用注解@RequestParam直接获取. 1.获取 ...

  8. 【转】springmvc @RequestParam

    在SpringMVC后台控制层获取参数的方式主要有两种,一种是request.getParameter("name"),另外一种是用注解@RequestParam直接获取.这里主要 ...

  9. springboot springmvc 抛出全局异常解决方法

    springboot中抛出异常,springboot自带的是springmvc框架,这个就不多说了. springmvc统一异常解决方法这里要说明的是.只是结合了springboot的使用而已.直接上 ...

  10. SpringMvc@RequestParam 来映射请求参数

    jsp页面 <a href="springmvc/testRequestParam?username=atguigu&age=11">Test RequestP ...

随机推荐

  1. 【Java基础-实验7】Banking_7 -添加银行透支扣款系统的 thorw异常机制

    实验基本要求: 实验题目 7:(在6基础上修改) 将建立一个 OverdraftException 异常,它由 Account 类的withdraw()方法 抛出. 实验目的: 自定义异常 实验说明: ...

  2. Procomm Plus 与ASPECT脚本语言在基于远程终端设备上的测试应用

    产测 ---------------------------------------------------- 原文:http://www.bixuanzl.com/20180801/1084478. ...

  3. python ini文件内容的读取

    (1)新建一个项目,再次新建一个文件 test_cfg.ini (2)再次新建 get_test_cfg.py,用来读取/写入/更改 ini的文件内容 #!/usr/bin/env python # ...

  4. redis 订阅&发布(转载)

    https://segmentfault.com/a/1190000016898228?utm_source=coffeephp.com 方法一: redis_helper.py: 封装发布订阅方法 ...

  5. 15、Spring Boot 2.x 集成 Swagger UI

    1.15.Spring Boot 2.x 集成 Swagger UI 完整源码: Spring-Boot-Demos 1.15.1 pom文件添加swagger包 <swagger2.versi ...

  6. 一个项目中:只能存在一个 WebMvcConfigurationSupport (添加swagger坑)

    问题再现: 1.添加了swagger配置,导致接口响应的中文乱码 2.于是又添加了配置解决中文乱码的配置: 问题来了,添加了CharsetConfig 配置后swagger的配置失效了,访问404,搞 ...

  7. Prometheus HA详解

    Prometheus 横向扩展 当Exporter或者采集信息需要越来越多时就会考虑高可用,高可用优点不会因为集群中某个节点down而导致Prometheus不可用,可以让算力下沉; 缺点是A-Pro ...

  8. springboot+druid+sqlite遇到的问题

    1.springboot中使用druid查询sqlite报错getFetchDirection error ResultSet closed https://blog.csdn.net/u011943 ...

  9. 第04组 Beta冲刺(1)

    队名:斗地组 组长博客:地址 作业博客:Beta冲刺(1/4) 各组员情况 林涛(组长) 过去两天完成了哪些任务: 1.分配展示任务 2.收集各个组员的进度 3.写博客 展示GitHub当日代码/文档 ...

  10. DBCA创建数据库

    工具/原料 oracle database 11g 步骤/方法 1 确保安装好oracle database 11g 2 打开命令提示符(运行中输入CMD打开 或是在 附件中点击打开) 3 输入dbc ...