zoukankan      html  css  js  c++  java
  • 前端html用一个表单来映射后台多个对象

    public class entity1 {
    
        
        private String id;
        public String getId() {
            return id;
        }
        public void setId(String id) {
            this.id = id;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        private String name;
        
        
        
    }
    
    public class entity2 {
    
        
        private String id;
        public String getId() {
            return id;
        }
        public void setId(String id) {
            this.id = id;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        private String name;
        
        
        
    }
    
    public class entity3 {
    
        
        private String id;
        public String getId() {
            return id;
        }
        public void setId(String id) {
            this.id = id;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        private String name;
        
        
        
    }
    public class mytestAction extends ActionSupport{
        
        
        
        private entity1 entity1;
        private entity2 entity2;
        private entity3 entity3;
        
        
        public String save()
        {
           return "success"
             
        }
    }

    技术交流QQ群:15129679

    <!DOCTYPE HTML>
    <html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        
        <form action="">
        
            <input type="text" name="entity1.id" />
            <input type="text" name="entity1.name" />
            
            <input type="text" name="entity2.id" />
            <input type="text" name="entity2.name" />
            
            <input type="text" name="entity3.id" />
            <input type="text" name="entity3.name" />
        
        
        
        
        
        
        
        </form>
        
        
        
        
    </body>
    </html>

    表的name值我们用了对象的名称然后序列化表单提交到后台,后台就映射到了三个对象是不是很easy!

  • 相关阅读:
    VS2015预览版中的C#6.0 新功能(一)
    REST总结
    MVC和传统的以模板为中心的web架构比较
    实现两个select list box间item的移动和过滤
    异步编程
    简述System.Windows.Forms.Timer 与System.Timers.Timer用法区别
    C#导出EXCEL,并生成charts表
    CRC16位校验
    c# 后台GET、POST、PUT、DELETE传输发送json数据
    UDP通讯
  • 原文地址:https://www.cnblogs.com/yeminglong/p/6766943.html
Copyright © 2011-2022 走看看