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";
    }
}
相关推荐
967711 分钟前
什么是 Thymeleaf?
java
Dream_sky分享18 分钟前
找类中字段属性不同工具类
java
givemeacar23 分钟前
SpringBoot3.3.0集成Knife4j4.5.0实战
java
十六年开源服务商28 分钟前
家庭装修公司网站方案策划2026
java·开发语言
XiYang-DING33 分钟前
【Java】TOP-K问题
java·开发语言
CHANG_THE_WORLD34 分钟前
模拟解析:宽度数组 `[1,2,1]`,10个条目的 XRef 流
java·前端·算法
MyY_DO40 分钟前
布隆过滤器todo
java
砍材农夫42 分钟前
spring-ai 第五模型介绍
java·人工智能·spring
mu_guang_44 分钟前
计算机体系结构2-内存一致性
java·后端·spring·计算机体系结构
小旭95271 小时前
SpringBoot + 七牛云 + Quartz:图片存储与定时清理
java·spring boot·后端·mybatis