• springmvc对象作为 目标方法的参数。


    /**
         * Spring MVC 会按请求参数名和 POJO 属性名进行自动匹配, 自动为该对象填充属性值。支持级联属性。
         * 如:dept.deptId、dept.address.tel 等
         */
        @RequestMapping("/testPojo")
        public String testPojo(User user){
            System.out.println(user);
            return SUCCESS;
        }

    user对象:

    package com.springmvc.entities;
    
    public class User {
        private String username;
        private Integer age;
        private Address address;
        public String getUsername() {
            return username;
        }
        public void setUsername(String username) {
            this.username = username;
        }
        public Integer getAge() {
            return age;
        }
        public void setAge(Integer age) {
            this.age = age;
        }
        public Address getAddress() {
            return address;
        }
        public void setAddress(Address address) {
            this.address = address;
        }
        @Override
        public String toString() {
            return "User [username=" + username + ", age=" + age + ", address="
                    + address + "]";
        }
        
    }

    Address对象

    package com.springmvc.entities;
    
    public class Address {
        private String city;
        private String country;
        public String getCity() {
            return city;
        }
        public void setCity(String city) {
            this.city = city;
        }
        public String getCountry() {
            return country;
        }
        public void setCountry(String country) {
            this.country = country;
        }
        @Override
        public String toString() {
            return "Address [city=" + city + ", country=" + country + "]";
        }
        
    }
  • 相关阅读:
    Adobe Photoshop cs6 破解方法
    vs2008试用90天破解方法
    Install win8_pro using UltraISO
    面试题-100盏灯问题
    PHP 博客文集 1 Veda原型 成功,唯有积累,没有奇迹
    php 框架
    php 语法2
    干货 连接
    试题 极客学院
    地图
  • 原文地址:https://www.cnblogs.com/bulrush/p/8030584.html
Copyright © 2020-2023  润新知