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";
    }
}
相关推荐
黑眼圈子几秒前
Java正则表达式基础知识
java·开发语言·正则表达式
iPadiPhone1 分钟前
性能优化的“快车道”:Spring @Async 注解深度原理与大厂实战
java·后端·spring·面试·性能优化
彭于晏Yan1 分钟前
JsonProperty注解的access属性
java·spring boot
Mr.朱鹏8 分钟前
分布式-redis集群架构
java·redis·分布式·后端·spring·缓存·架构
予枫的编程笔记8 分钟前
【面试专栏|Java并发编程】Java并发锁对比:synchronized与Lock,底层原理+适用场景详解
java·synchronized·java面试·java并发编程·并发锁·面试干货·lock接口
醇氧10 分钟前
PowerPoint 批量转换为 PDF
java·spring boot·spring·pdf·powerpoint
java1234_小锋11 分钟前
Java高频面试题:RabbitMQ如何实现消息的持久化?
java·开发语言
爱打代码的小林18 分钟前
用 LangChain 解析大模型输出
java·python·langchain·大模型
_日拱一卒20 分钟前
LeetCode(力扣):只出现一次的数字
java·数据结构·算法
小箌21 分钟前
JavaWeb_02
java·数据库·maven·mybatis