javaee springMVC绑定复杂对象

jsp

html 复制代码
<%--
  Created by IntelliJ IDEA.
  User: HIAPAD
  Date: 2019/11/29
  Time: 14:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<form action="users/addUser" method="post">

    <pre>
    用户名:<input type="text" name="uname" />
    密码:<input type="password" name="pwd" />
    地址:<input type="text" name="address.detail" />
    <input type="submit" name="sub" value="提交" />

    </pre>
</form>


</body>
</html>

java

java 复制代码
package com.test.controller;

import com.test.pojo.Users;
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;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/users")
public class UsersController {

    @RequestMapping("/addUser")
    public String addUser(Users user)
    {
         System.out.println(user);

         return "success";
    }
}
相关推荐
ZLZQ_Yuan1 分钟前
线程池使用
java
不爱吃糖的程序媛2 分钟前
鸿蒙PC端Java应用开发实战:从环境适配到系统信息采集
java·华为·harmonyos
鹿角片ljp3 分钟前
深入理解Java集合框架:核心接口与实现解析
java·开发语言·windows
小贝IT~11 分钟前
基于SpringBoot的网页时装购物系统-049
java·spring boot·后端
独自破碎E20 分钟前
什么是循环依赖
java·mysql·mybatis
heartbeat..20 分钟前
Java NIO 详解(Channel+Buffer+Selector)
java·开发语言·文件·nio
2401_8370885023 分钟前
Hot 146 LRU Cache 实现详解
java·开发语言
悟空码字26 分钟前
文档变形记,SpringBoot实战:3步让Word乖乖变PDF
java·spring boot·后端
用户21903265273529 分钟前
能省事”。SpringBoot+MyBatis-Plus:开发效率提升10倍!
java·spring boot·mybatis