标签:map return spring framework not and src handle (九)
通过在控制器方法中使用@RequestParam(value="参数名",require=true/false,defaultvalue="")的方式,使在URL中传入参数。
控制器代码:
package com.tiekui.springmvc.handlers; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @Controller public class RequestParamTest { @RequestMapping("testRequestParam") public String testRequestParam(@RequestParam(value="id",required=false,defaultvalue="10") Integer id){ System.out.println(id); return "success"; } }
视图代码:
<a href="testRequestParam?id=3">TestRequestParam</a>
SpringMVC(九) RequestMapping请求参数
标签:map return spring framework not and src handle (九)
原文地址:https://www.cnblogs.com/yuyu666/p/10050054.html