1.@RequestParam

  1. @RequestMapping(value = "/xxxx.do")
  2. public void create(@RequestParam(value="userName") String userName) throws Exception {
  3. }
	@RequestMapping(value = "/xxxx.do")
public void create(@RequestParam(value="userName") String userName) throws Exception { }

2.@PathVariable

  1. @RequestMapping(value="/{groupId}.do")
  2. public void detail(@PathVariable long groupId){
  3. groupRepository.selectOne(groupId);
  4. }
	@RequestMapping(value="/{groupId}.do")
public void detail(@PathVariable long groupId){
groupRepository.selectOne(groupId);
}

3.@ModelAttribute

  1. @RequestMapping(value = "/xxxx.do")
  2. public String create(@ModelAttribute User user) throws Exception {
  3. userService.insert(user);
  4. return "redirect:/user/create.do";
  5. }
	@RequestMapping(value = "/xxxx.do")
public String create(@ModelAttribute User user) throws Exception {
userService.insert(user);
return "redirect:/user/create.do";
}

4.Request对象

  1. public ModelAndView method1(HttpServletRequest request,
  2. HttpServletResponse respnose) throws ServletException, IOException {
  3. Map model = new HashMap();
  4. model.put("message", "你调用的是方法1");
  5. return new ModelAndView("/index.jsp", "model", model);
  6. }

SpringMVC 接收表单数据的方式 - Samuel - 博客频道 - CSDN.NET的更多相关文章

  1. SpringMVC 接收表单数据的方式

    1.@RequestParam @RequestMapping(value = "/xxxx.do") public void create(@RequestParam(value ...

  2. SpringMVC 接收表单数据、数据绑定、解决请求参数中文乱码

    接收表单数据有3种方式. 1.使用简单类型接收表单数据(绑定简单数据类型) 表单: <form action="${pageContext.request.contextPath}/u ...

  3. docker mysql 数据持久化到本地、设置不区别表名大小写-清风柳絮-51CTO博客

    原文:docker mysql 数据持久化到本地.设置不区别表名大小写-清风柳絮-51CTO博客 Docker MySQL 把数据存储在本地目录,很简单,只需要映射本地目录到容器即可 1.加上-v参数 ...

  4. myssql数据库表名转驼峰 - PLAY - ITeye博客

    原文:myssql数据库表名转驼峰 - PLAY - ITeye博客

  5. js清空表单数据的方式(遍历+reset)

    方法1:遍历页面元素 /* 清空FORM表单内容 id:表单ID*/ function ClearForm(id) { var objId = document.getElementById(id); ...

  6. springmvc接收json数据的常见方式

    经常使用Ajax异步请求来进行数据传输,传的数据是json数据,json数据又有对象,数组.所有总结下springmvc获取前端传来的json数据方式:1.以RequestParam接收前端传来的是j ...

  7. servlet获取表单数据的方式和编码方式

    .在servlet中获取表单的数据的几种方式  1>request.getParameter(“name”)://获取指定名称的值,返回值类型是一个字符串  2>request.getPa ...

  8. SpringMVC接收前端传值有哪些方式?

    有很多种,比如: 1.通过@RequestParam注解接收请求参数: 2.通过Bean封装,接收多个请求参数 3.通过@ModelAttribute绑定接收前端表单数据 4.通过@PathVaria ...

  9. springMVC接收参数的几种方式

    Spring3 MVC请求参数获取的几种方法 一.      通过@PathVariabl获取路径中的参数 @RequestMapping(value="user/{id}/{name}&q ...

随机推荐

  1. mxml日期显示使用

    mxml代码: <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx= ...

  2. go mode

    https://github.com/dominikh/go-mode.el http://blog.altoros.com/golang-part-1-main-concepts-and-proje ...

  3. wpf中ListBox的选中项与ComboBox间的绑定

    产品类: public class Product:NotificationObject { private int productID; public int ProductID { get { r ...

  4. ios开发使用lipo命令合并真机库和模拟器库

    在开发ios时,我们经常会遇到编译两套库文件,使用模拟器时链接模拟器库,使用真机时使用真机库,这样操作会对后期的维护带来麻烦,所以Apple提供了一个把多个不同平台的.a库文件合并成一个适用于多平台的 ...

  5. UVA - 11732 "strcmp()" Anyone?左兄弟右儿子trie

    input n 2<=n<=4000 s1 s2 ... sn 1<=len(si)<=1000 output 输出用strcmp()两两比较si,sj(i!=j)要比较的次数 ...

  6. 安卓常用 widget

    验证码 public class SpinnerImg extends ImageView { /** * 完成选择后启动另外一个spinner */ private ItemListener ite ...

  7. map & flatMap 浅析

    我之前一直以为我是懂 map 和 flatMap 的.但是直到我看到别人说:「一个实现了 flatMap 方法的类型其实就是 monad.」我又发现这个熟悉的东西变得陌生起来,本节烧脑体操打算更细致一 ...

  8. 深入解析FileInputStream和FileOutputStream

    http://swiftlet.net/archives/1363 FileInputStream和FileOutputStream类属于字节类,可以操作任意类型的文件.在数据流的处理过程中,有两种情 ...

  9. html base2

    <html> <body> <h1>My First Web Page</h1> <p id="demo">A Para ...

  10. 使用log4j无法输出日志

    前段时间在项目的过程中使用log4j来输出日志,但是在一个项目里我明明已经在src/main/resource目录下创建了log4j.properties.具体配置如下: log4j.rootLogg ...