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";
    }
}
相关推荐
FreeGo~几秒前
Linux 系统编程 进程篇 (五)
java·linux·服务器
XiYang-DING20 分钟前
【Java EE】定时器
java·python·java-ee
Fuly102424 分钟前
java面试知识点复习
java·开发语言·面试
信徒_1 小时前
API 网关技术选型
java
simple-L61 小时前
Java开发痛点技术文章大纲
java·开发语言
千寻girling1 小时前
滑动窗口刷了快一个月(26天)了 , 还没有刷完. | 含(操作系统学什么的Java 后端)
java·开发语言·javascript·c++·人工智能·后端·python
小手cool1 小时前
Java字符串按空行分割,包括末尾的空行
java
呱牛do it2 小时前
企业级门户网站设计与实现:基于SpringBoot + Vue3的全栈解决方案(Day 9)
java
鸡蛋灌Bean2 小时前
mybatis分页深入了解
java·数据库·mybatis
野生技术架构师2 小时前
Tomcat Service的设计和实现:StandardService
java·tomcat