Spring MVC How take the parameter value of a GET HTTP Request in my controller method?
2015-09-22 11:54
681 查看
In this periodo I am studing the Spring MVC showcase example (downloadable from STS dasboard) and I have some simple question about the “Request Mapping” examples:
1) In my home.jsp page I have this link:
As you can see by this link I am doing an HTTP GET Request having a “
This HTTP Request is handled by the following method of the controller class
This method manage HTTP Request (only GET type) that have a parameter named “foo”
How can I take the value (“bar”) of this parameter and put it in a variable inside the code of my by Parameter method?
As explained in the documentation, by using an
1) In my home.jsp page I have this link:
<li> <a id="byParameter" class="textLink" href="<c:url value="/mapping/parameter?foo=bar" />">By path, method, and presence of parameter</a> </li>
As you can see by this link I am doing an HTTP GET Request having a “
foo” parameter containing the value: “
bar“.
This HTTP Request is handled by the following method of the controller class
MappingController:
@RequestMapping(value="/mapping/parameter", method=RequestMethod.GET, params="foo") public @ResponseBody String byParameter() { return "Mapped by path + method + presence of query parameter! (MappingController)"; }
This method manage HTTP Request (only GET type) that have a parameter named “foo”
How can I take the value (“bar”) of this parameter and put it in a variable inside the code of my by Parameter method?
As explained in the documentation, by using an
@RequestParamannotation:
public @ResponseBody String byParameter(@RequestParam("foo") String foo) { return "Mapped by path + method + presence of query parameter! (MappingController) - foo = " + foo; }
相关文章推荐
- 分享微信开发Html5轻游戏中的几个坑
- Zend的MVC机制使用分析(二)
- ASP.NET MVC 4 捆绑和缩小实例介绍
- ASP.NET MVC中将控制器分离到类库的实现
- asp.net实现在非MVC中使用Razor模板引擎的方法
- ASP.NET MVC中的AJAX应用
- 如何在MVC应用程序中使用Jquery
- ASP.NET MVC小结之基础篇(二)
- ASP.NET小结之MVC, MVP, MVVM比较以及区别(一)
- Asp.net实现MVC处理文件的上传下载功能实例教程
- ASP.NET MVC小结之基础篇(一)
- Flex中最好的MVC框架Mate框架
- ASP.NET MVC学习笔记
- 关于php mvc开发模式的感想
- php打造属于自己的MVC框架
- 使用ASP.NET MVC 4 Async Action+jQuery实现消息通知机制的实现代码
- mvc下,3种窗口弹出设置的方法
- ASP.NET MVC运行出现Uncaught TypeError: Cannot set property __MVC_FormValidation of null的解决方法
- PHP发明人谈MVC和网站设计架构 貌似他不支持php用mvc
- JSP开发中在spring mvc项目中实现登录账号单浏览器登录