Bean:

  public class User {
      private String name;
      private String password;
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public String getPassword() {
          return password;
      }
      public void setPassword(String password) {
          this.password = password;
      }  
  }

Controller代码:

@RequestMapping("addUser")
    public String addUser(User user){
        userServiceImp.addUser(user);
        System.out.println("---------------------------------");
        return "success";

  }

表单代码:

  <p>添加用户</p>
  <form action="addUser.do" method="post">
      userName:<input type="text" name="name"/><br/>
      password:<input type="text" name="password">
      <input type="submit"/>
  </form>

只需将对象的属性名和input的name值匹配即可。

SpringMVC的controller方法上若需要参数 如User的更多相关文章

  1. SpringMVC基础-controller方法中的参数注解

    @PathVariable  映射 URL 绑定的占位符 带占位符的 URL 是 Spring3.0 新增的功能,该功能在 SpringMVC 向 REST 目标挺进发展过程中具有里程碑的意义 通过 ...

  2. SpringMVC的Controller方法的参数不能直接绑定List、Set、Map

    List需要绑定在对象上,而不能直接写在Controller方法的参数中. http://www.iteye.com/topic/973918

  3. springmvc中Controller方法的返回值

    1.1 返回ModelAndView controller方法中定义ModelAndView对象并返回,对象中可添加model数据.指定view. 1.2 返回void 在controller方法形参 ...

  4. SpringMVC的controller方法中注解方式传List参数使用@RequestBody

    在SpringMVC控制器方法中使用注解方式传List类型的参数时,要使用@RequestBody注解而不是@RequestParam注解: //创建文件夹 @RequestMapping(value ...

  5. SpringMVC中 controller方法返回值

    1)ModelAndView @RequestMapping(value="/itemEdit") public ModelAndView itemEdit(){ //创建模型视图 ...

  6. SpringMVC学习记录五——功能开发及参数处理

    15       包装类型pojo参数绑定 15.1      需求 商品查询controller方法中实现商品查询条件传入. 15.2      实现方法 第一种方法:在形参中 添加HttpServ ...

  7. springMVC中controller的传参的几种案例

    1.springmvc的controller方法不指定method时,默认get/post都支持 //@RequestMapping(value="test") //@Reques ...

  8. 使用getParameterMap()方法实现对请求参数的封装的工具类

    我们知道,HttpServletRequest这个类的getParameter(name),getParameterValues(name)可以分别实现对页面传来的单个参数和对多个同名参数的接受.特别 ...

  9. SpringMVC入门(二)—— 参数的传递、Controller方法返回值、json数据交互、异常处理、图片上传、拦截器

    一.参数的传递 1.简单的参数传递 /* @RequestParam用法:入参名字与方法名参数名不一致时使用{ * value:传入的参数名,required:是否必填,defaultValue:默认 ...

随机推荐

  1. Oracle Hang分析--转载

    1. 数据库hang的几种可能性 oracle 死锁 或者系统负载非常高比如cpu使用或其他一些锁等待很高都可能导致系统hang住,比如大量的DX锁. 通常来说,我们所指的系统hang住,是指应用无响 ...

  2. xcode 插件地址

    http://finalshares.com/read-1104 curl -fsSL https://raw.githubusercontent.com/supermarin/Alcatraz/de ...

  3. Xilinx FPGA全局时钟和全局时钟资源的使用方法

    对FPGA的全局时钟了解不多,遂转载一篇文档: http://xilinx.eetop.cn/?action-viewnews-itemid-42 目前,大型设计一般推荐使用同步时序电路.同步时序电路 ...

  4. Python-6 分支 循环

    #1 循环 while 条件: 循环体 for 目标 in 表达式: 循环体   表达式可为:range(start,stop,step) break--终止当前循环,并跳出当前循环体. contin ...

  5. SQL语句的增删查改

    一.增:有2种方法 1.使用insert插入单行数据: 语法:insert [into] <表名> [列名] values <列值> 例:insert into Strdent ...

  6. 思考力——提升企业竞争力的核心因素

    如果你对项目管理.系统架构有兴趣,请加微信订阅号"softjg",加入这个PM.架构师的大家庭 · 思考力就是竞争力:在这个科技飞跃进步的时代,很多事物是我们未曾经历也难以预料的. ...

  7. Action向前台输出

    import java.io.IOException;import java.io.PrintWriter; import javax.servlet.http.HttpServletResponse ...

  8. sql: 去除数据库表中tab、空格、回车符等特殊字符的解决方法

    去除tab.空格.回车符等使用replace语句 按照ASCII码, SELECT char(64) 例如64 对应 @,则select REPLACE('abc@qq.com',char(64),' ...

  9. windows下git识别大小写配置

    默认情况下windows上的Git客户端,在文件名仅发生大小写改变时不会识别,提交后发现,gitlab上的文件名不会发生变化. 解决方法: 编辑 .git 中的config文件, 将 ignoreca ...

  10. Dev ChartControl鼠标移动显示坐标点

    his.chartIRC_RATES.MouseMove += new MouseEventHandler(chartIRC_RATES_MouseMove); ToolTipController t ...