SpringMVC中@RequestParam注解作用
1.不使用@RequestParam
请求参数名必须和形参名称一样
2.使用@RequestParam
请求参数名必须和@RequestParam value属性值一样
请求参数名不必和形参名称一样
3个属性的使用
value
required:请求参数是否必须传入
defaultValue:请求参数的默认值,如果请求参数没有传入,则将默认值与形参进行绑定
例子:
//method:限制请求方法
@RequestMapping(value="/getItems.action",method = { RequestMethod.POST,RequestMethod.GET })
public String getItems(Model model,@RequestParam(value="id",required=false,defaultValue = "1") Integer itemsId) {
ItemsCustom itemsCustom = this.itemsService.getItems(itemsId);
model.addAttribute("itemsCustom", itemsCustom);
return "items/editItems"; //返回的是逻辑视图(前缀+逻辑视图+后缀=物理视图路径)
}
SpringMVC中@RequestParam注解作用的更多相关文章
- springMVC中@RequestParam和@RequestBody注解的用法
springMVC中@RequestParam注解用在Controller层获解析.提取参数,当然你也可以用request.getParameter("name")来获取参数,而@ ...
- SSM-SpringMVC-14:SpringMVC中大话注解式开发基础--呕心沥血版
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 注解的基础我不再多啰嗦,百度一搜很多,很详细啊,我就讲一下SpringMVC中的注解入门 通过注解的方式定义 ...
- SpringMVC 中 @ControllerAdvice 注解
SpringMVC 中 @ControllerAdvice 注解 1.@ControllerAdvice 1.1 全局异常处理 1.2 全局数据绑定 1.3 全局数据预处理 原文地址: 江南一点雨:S ...
- springMVC中的注解@RequestParam与@PathVariable的区别
1.@PathVariable @PathVariable绑定URI模板变量值 @PathVariable是用来获得请求url中的动态参数的 @PathVariable用于将请求URL中的模板变量映射 ...
- SpringMVC 中的注解@RequestParam与@PathVariable的区别
@PathVariable绑定URI模板变量值 @PathVariable是用来获得请求url中的动态参数的 @PathVariable用于将请求URL中的模板变量映射到功能处理方法的参数上.//配置 ...
- Spring|SpringMVC中的注解
文章目录 一.Spring注解 @Controller @ResuController @Service @Autowired @RequestMapping @RequestParam @Model ...
- springmvc中ModelAttribute注解应用在参数中
可以用@ModelAttribute来注解方法参数或方法.带@ModelAttribute创建的参数对象会被添加到Model对象中.注解在参数上时,可以从Form表单或URL参数中获取参数并绑定到mo ...
- springMVC中@RequestParam和@RequestBody的作用
@RequestParam和@RequestBody是什么区别,估计很多人还是不太清楚, 因为一般用@ RequestParam就足够传入参数了,要说他们区别,就需要知道contentType是什么? ...
- SpringMVC中 -- @RequestMapping的作用及用法
一.@RequestMapping 简介 在Spring MVC 中使用 @RequestMapping 来映射请求,也就是通过它来指定控制器可以处理哪些URL请求,相当于Servlet中在web.x ...
随机推荐
- python windows下获取路径时有中文处理
在windows中用os,path.abspath(__file__)时有中文路径时,默认是转成非unicode格式 这会导致,在其它模块使用该路径时,会报 utf8' codec can't dec ...
- centos定时删除log文件
#!bin/bash #获取年 time=$(date "+%Y") #查找并删除7天前的文件 find /opt/applog/travelsky -type f -mtime ...
- hadoop exit code 退出码含义
原文传送门:http://www.2cto.com/database/201308/236519.html "OS error code 1: Operation not permitted ...
- learning shell check requires root privileges
[Purpose] Shell script check requires root privileges [Eevironment] Ubuntu 16.04 bas ...
- A Deep Dive into PL/v8
Back in August, Compose.io announced the addition of JavaScript as an internal language for all new ...
- ORA-25153错误及解决办法
出现下图错误 原因就是没有临时表空间,所以要建立临时表空间,下面的语句,记得把地址换成你自己想放的地方. alter tablespace temp add tempfile 'C:/temp.dbf ...
- debian/ubuntu安装mssql
添加源: debian源:deb [arch=amd64] https://packages.microsoft.com/debian/10/prod buster main ubuntu源:deb ...
- TensorFlow中的 tensor 张量到底是什么意思?
详见[Reference]: TensorFlow中的“Tensor”到底是什么? 以下摘录一些要点: 这个图好生动呀!~ 标量和向量都是张量(tensor).
- 关于jsruntime 的概念
In the JSAPI, JSRuntime is the top-level object that represents an instance of the JavaScript engine ...
- Appium+iOS真机环境搭建
安装目录 1.macOS系统 10.12.6 2.xcode 9.0 3.appium Desktop 1.12.1 4.node.js node -v npm 5.cnpm npm insta ...