0
点赞
收藏
分享

微信扫一扫

映射请求参数&请求参数


映射请求参数&请求参数_spring mvc

映射请求参数&请求参数_数据_02

如果方法为如下的形式:

映射请求参数&请求参数_spring_03

即age的类型为@RequestParam(value="age", required=false) int age,那么如果我们采用如下的形式来访问:

​​http://localhost:8080/Spring4/springmvc/testRequestParam?username=atguigu​​

映射请求参数&请求参数_mvc_04

即无法把null值转换为int类型的数据;

可以修改为@RequestParam(value="age", required=false) Integer age  或者

@RequestParam(value="age", required=false, defaultValue="0") int age

映射请求参数&请求参数_spring mvc_05


映射请求参数&请求参数_数据_06

映射请求参数&请求参数_spring_07

映射请求参数&请求参数_spring mvc_08


映射请求参数&请求参数_mvc_09

映射请求参数&请求参数_spring_10

映射请求参数&请求参数_数据_11

映射请求参数&请求参数_mvc_12

映射请求参数&请求参数_mvc_13

映射请求参数&请求参数_数据_14

                                     图:SpringMVC源码部分对请求类型转换的解读


映射请求参数&请求参数_mvc_15

                        图:利用Writer对象来输出数据信息,从上面的源代码可以看出,Writer就是response.getWriter()方法返回的对象

映射请求参数&请求参数_spring_16


举报

相关推荐

0 条评论