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";
    }
}
相关推荐
像我这样帅的人丶你还5 小时前
Java 后端详解(四):分页与搜索
java·javascript·后端
她的男孩5 小时前
数据权限为什么不能只靠注解?Forge 的 Mapper 层 SQL 改写源码拆解
java·后端·架构
tntxia6 小时前
Mybatis的日志输入
java
亦暖筑序7 小时前
Java 8老系统Browser Agent实战:三层拦截把AI操作后台变成可审计流程
java·后端·设计模式
用户2986985301410 小时前
Java 实现 Word 文档加密与权限解除
java·后端
Yeats_Liao11 小时前
14:Servlet中的页面跳转-Java Web
java·后端·架构
未秃头的程序猿11 小时前
告别"if-else地狱"!Java 21模式匹配,代码优雅了10倍
java·后端·面试
鹤望兰67511 小时前
字节跳动国际支付-后端开发-三面面经
java
Flittly11 小时前
【AgentScope Java新手村系列】(14)人机交互
java·spring boot·spring
RainCity11 小时前
Java Swing 自定义组件库分享(十二)
java·笔记·后端