博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SpringMVC-@RequestParam
阅读量:6853 次
发布时间:2019-06-26

本文共 1392 字,大约阅读时间需要 4 分钟。

请求处理方法签名

 承接一二章

 

springmvc通过分析处理方法的签名,将http请求信息绑定到处理方法的相应参数中。并根据方法的返回质类型作出相应的后续处理。

必要时可以对其方法及方法参数标注相应的注解。如:@PathVariable @RequestParam @RequestHeader

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%>
Hello World hhhhhhhhh
可以传参数默认是必须的

test.java

package com.hdxy.domian;import java.lang.reflect.Method;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RequestParam;/** * @author 流年拓荒者 * required=false :设置此参数是不是必须的。默认为turn *defaultValue="0"默认为0 */@RequestMapping("springMVC")@Controllerpublic class Test {   final public String SUCCESS="loginSuccess";     @RequestMapping(value="/testRest")   public String testRequestParam(@RequestParam(value="name") String un,@RequestParam(value="age")String age){       System.out.println("testRequestParam"+un+age);       return SUCCESS;   }      @RequestMapping(value="/testRest1")   public String testsRequestParam(@RequestParam(value="name") String un,@RequestParam(value="age",required=false,defaultValue="0")int age){       System.out.println("testRequestParam"+un+age);       return SUCCESS;   }}

 

转载于:https://www.cnblogs.com/lnthz/p/8024951.html

你可能感兴趣的文章
jQuery EasyUI实现关闭全部tabs
查看>>
poj3635Full Tank?[分层图最短路]
查看>>
【USACO 1.4】Mother's Milk
查看>>
CentOs 设置静态IP 方法
查看>>
使用Maven构建多模块项目
查看>>
李洪强经典面试题47--UNIX常用命令
查看>>
angularjs中templateUrl的路径问题
查看>>
Linux 命令详解(三)./configure、make、make install 命令
查看>>
分享Kali Linux 2017年第31周镜像文件
查看>>
03-老马jQuery教程-DOM操作
查看>>
mongodb09----replicattion set--健壮性
查看>>
sql中的笛卡尔积
查看>>
C Array length function problem - C / C++
查看>>
ASP.NET中26个常用性能优化方法
查看>>
Objective-C利用协议实现回调函数
查看>>
angularjs的$window功能小练习
查看>>
Bayesian generalized linear model (GLM) | 贝叶斯广义线性回归实例
查看>>
Pulsar-Producer实现简介
查看>>
<转载>构造函数与拷贝构造函数
查看>>
[转]K近邻算法
查看>>