zoukankan      html  css  js  c++  java
  • 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 + "]";
        }
        
    }
  • 相关阅读:
    [转]OLAP的12条准则
    这几年
    方法论
    用NetHogs监控Linux每个进程的网络使用情况
    Centos下文本文件格式转码解决
    CentOS+Puppet分布式部署Zabbix监控系统
    ubuntu修复grub,u盘引导问题
    postfix搭建纯邮件转发服务器
    Mysql: 利用强制索引去掉重数据
    shell 变量赋值与替换
  • 原文地址:https://www.cnblogs.com/bulrush/p/8030584.html
Copyright © 2011-2022 走看看