動態數據與後臺交互的兩種方式

来源:http://www.cnblogs.com/xuanaiwu/archive/2016/11/12/6057383.html
-Advertisement-
Play Games

第一種方式: javabean: 1 public class BusLoanInfoShop { 2 private Integer id; 3 private Integer bid; 4 private String shopName; 5 private String platformNam ...


第一種方式:

javabean:

  1 public class BusLoanInfoShop {
  2     private Integer id;
  3     private Integer bid;
  4     private String shopName;
  5     private String platformName;
  6     private String shopLevel;
  7     private String operatingPeriod;
  8     private String shopOwner;
  9     private String subAccount;
 10     private String sbuPassword;
 11     private String businessOpera;
 12     private String businessAddress;
 13     private String warehouseAddress;
 14     private String salesIncome;
 15     private String totalLiability;
 16     private String bankLiabilities;
 17     private String netProfit;
 18 
 19     public Integer getId() {
 20         return id;
 21     }
 22     public void setId(Integer id) {
 23         this.id = id;
 24     }
 25     public Integer getBid() {
 26         return bid;
 27     }
 28     public void setBid(Integer bid) {
 29         this.bid = bid;
 30     }
 31     public String getShopName(){
 32         return this.shopName;
 33     }
 34     public void setShopName(String shopName){
 35         this.shopName=shopName;
 36     }
 37     public String getPlatformName(){
 38         return this.platformName;
 39     }
 40     public void setPlatformName(String platformName){
 41         this.platformName=platformName;
 42     }
 43     public String getShopLevel(){
 44         return this.shopLevel;
 45     }
 46     public void setShopLevel(String shopLevel){
 47         this.shopLevel=shopLevel;
 48     }
 49     public String getOperatingPeriod(){
 50         return this.operatingPeriod;
 51     }
 52     public void setOperatingPeriod(String operatingPeriod){
 53         this.operatingPeriod=operatingPeriod;
 54     }
 55     public String getShopOwner(){
 56         return this.shopOwner;
 57     }
 58     public void setShopOwner(String shopOwner){
 59         this.shopOwner=shopOwner;
 60     }
 61     public String getSubAccount(){
 62         return this.subAccount;
 63     }
 64     public void setSubAccount(String subAccount){
 65         this.subAccount=subAccount;
 66     }
 67     public String getSbuPassword(){
 68         return this.sbuPassword;
 69     }
 70     public void setSbuPassword(String sbuPassword){
 71         this.sbuPassword=sbuPassword;
 72     }
 73     public String getBusinessOpera(){
 74         return this.businessOpera;
 75     }
 76     public void setBusinessOpera(String businessOpera){
 77         this.businessOpera=businessOpera;
 78     }
 79     public String getBusinessAddress(){
 80         return this.businessAddress;
 81     }
 82     public void setBusinessAddress(String businessAddress){
 83         this.businessAddress=businessAddress;
 84     }
 85     public String getWarehouseAddress(){
 86         return this.warehouseAddress;
 87     }
 88     public void setWarehouseAddress(String warehouseAddress){
 89         this.warehouseAddress=warehouseAddress;
 90     }
 91     public String getSalesIncome(){
 92         return this.salesIncome;
 93     }
 94     public void setSalesIncome(String salesIncome){
 95         this.salesIncome=salesIncome;
 96     }
 97     public String getTotalLiability(){
 98         return this.totalLiability;
 99     }
100     public void setTotalLiability(String totalLiability){
101         this.totalLiability=totalLiability;
102     }
103     public String getBankLiabilities(){
104         return this.bankLiabilities;
105     }
106     public void setBankLiabilities(String bankLiabilities){
107         this.bankLiabilities=bankLiabilities;
108     }
109     public String getNetProfit(){
110         return this.netProfit;
111     }
112     public void setNetProfit(String netProfit){
113         this.netProfit=netProfit;
114     }
115 
116 }
javabean

ListForm:

 1 public class ShopListForm {
 2     private List<BusLoanInfoShop> shop;
 3 
 4     public List<BusLoanInfoShop> getShop() {
 5         return shop;
 6     }
 7 
 8     public void setShop(List<BusLoanInfoShop> shop) {
 9         this.shop = shop;
10     }
11 
12     
13 
14 }
ListForm

 

spring Mvc控制器入口:

1 @RequestMapping("/save")
2 public void save(ShopListForm shopForm,HttpServletResponse response) throws Exception{
3         for(BusLoanInfoShop shop:shopForm.getShop()){
4                 System.out.println("shop.name="+shop.getShopName());
5         }
6                 
7 }
spring mvc訪問入口

html代碼:

 1 <div id="optionContainer" class="ftitle">經驗實體信息(必填,多個網商店鋪需加行)</div>
 2                            <div class="fitem">  
 3                               <table id="tblShopData">
 4                                   <tr>
 5                                       <td>網店名稱</td>
 6                                       <td>電商平臺名稱</td>
 7                                       <td>網店級別(僅限淘寶及天貓商戶)</td>
 8                                       <td>網店持續經營年限</td>
 9                                       <td>網店實際所有者(個人名稱或公司名稱)</td>
10                                       <td>子帳號</td>
11                                       <td>密碼</td>
12                                       <td>主要產品、品牌</td>
13                                       <td>經營地址</td>
14                                       <td>倉庫地址</td>
15                                       <td>上年度銷售</td>
16                                       <td>總負債</td>
17                                       <td>銀行負債</td>
18                                       <td>上年度凈利潤</td>
19                                   </tr>
20                                   <tr id="tShopRow0">
21                                       <td>
22                                       <input id="shop[0].shopName" class="easyui-validatebox" name="shop[0].shopName" style="width:59px" data-options="required:true,validType:'length[1,200]'">
23                                       </td>
24                                       <td>
25                                       <input id="shop[0].platformName" class="easyui-validatebox" name="shop[0].platformName" style="width:59px" data-options="required:true,validType:'length[1,200]'">
26                                       </td>
27                                       <td>
28                                       <input id="shop[0].shopLevel" class="easyui-validatebox" name="shop[0].shopLevel" style="width:59px" data-options="required:true,validType:'length[1,100]'">
29                                       </td>
30                                       <td>
31                                       <input id="shop[0].operatingPeriod0" class="easyui-validatebox"  name="shop[0].operatingPeriod" style="width:59px" data-options="required:true,validType:'length[1,100]'">
32                                       </td>
33                                       <td>
34                                       <input id="shop[0].shopOwner" class="easyui-validatebox"  name="shop[0].shopOwner" style="width:59px" data-options="required:true,validType:'length[1,200]'">
35                                       </td>
36                                       <td>
37                                       <input id="shop[0].subAccount" class="easyui-validatebox"  name="shop[0].subAccount" style="width:59px" data-options="required:true,validType:'length[1,100]'">
38                                       </td>
39                                       <td>
40                                           <input id="shop[0].sbuPassword" class="easyui-validatebox" name="shop[0].sbuPassword" style="width:59px" data-options="required:true,validType:'length[1,100]'">
41                                       </td>
42                                       <td>
43                                           <input id="shop[0].businessOpera" class="easyui-validatebox"  name="shop[0].businessOpera" style="width:59px" data-options="required:true,validType:'length[1,300]'">
44                                       </td>
45                                       <td>
46                                           <input id="shop[0].businessAddress" class="easyui-validatebox" name="shop[0].businessAddress" style="width:59px" data-options="required:true,validType:'length[1,300]'">
47                                       </td>
48                                       <td>
49                                           <input id="shop[0].warehouseAddress" class="easyui-validatebox"  name="shop[0].warehouseAddress" style="width:59px" data-options="required:true,validType:'length[1,300]'">
50                                       </td>
51                                       
52                                       <td>
53                                           <input id="shop[0].salesIncome" class="easyui-validatebox" name="shop[0].salesIncome0" style="width:59px" data-options="required:true,validType:'length[1,100]'">
54                                       </td>
55                                       <td>
56                                           <input id="shop[0].totalLiability" class="easyui-validatebox"  name="shop[0].totalLiability" style="width:59px" data-options="required:true,validType:'length[1,100]'">
57                                       </td>
58                                       <td>
59                                           <input id="shop[0].bankLiabilities" class="easyui-validatebox" name="shop[0].bankLiabilities" style="width:59px" data-options="required:true,validType:'length[1,100]'">
60                                       </td>
61                                       <td>
62                                           <input id="shop[0].netProfit" class="easyui-validatebox" name="shop[0].netProfit" style="width:59px" data-options="required:true,validType:'length[1,100]'">
63                                       </td>
64                                       
65                                   </tr>
66                               </table>
67                               <br />
68                             <div style="text-align:center;">  
69                                   <a href="#" onclick="addShopRow()">添加一行</a>  
70                                   &nbsp;&nbsp;<a href="#" onclick="delShopRow()">刪除一行</a> 
71                             </div>    
72                        </div>   
html

 

js代碼:

 1 //添加行  
 2 function addShopRow(){
 3     var num=$("#rowCount").val();//取值
 4     num=parseInt(num);
 5     num++;
 6     $("#tShopRow0").clone(true).attr("id","tShopRow"+num).appendTo("#tblShopData");
 7     $("#tShopRow"+num+" td").each(function(){
 8         $(this).find("input[type='text']").val("");//清空數據
 9         $(this).find("input[name='shop[0].shopName']").attr("id","shop['"+num+"'].shopName").attr("name","shop['"+num+"'].shopName");
10         $(this).find("input[name='shop[0].platformName']").attr("id","shop['"+num+"'].platformName").attr("name","shop['"+num+"'].platformName");
11         $(this).find("input[name='shop[0].shopLevel']").attr("id","shop['"+num+"'].shopLevel").attr("name","shop['"+num+"'].shopLevel");
12         $(this).find("input[name='shop[0].operatingPeriod']").attr("id","shop['"+num+"'].operatingPeriod").attr("name","shop['"+num+"'].operatingPeriod");
13         $(this).find("input[name='shop[0].shopOwner']").attr("id","shop['"+num+"'].shopOwner").attr("name","shop['"+num+"'].shopOwner");
14         $(this).find("input[name='shop[0].subAccount']").attr("id","shop['"+num+"'].subAccount").attr("name","shop['"+num+"'].subAccount");
15         $(this).find("input[name='shop[0].sbuPassword']").attr("id","shop['"+num+"'].sbuPassword").attr("name","shop['"+num+"'].sbuPassword");
16         $(this).find("input[name='shop[0].businessOpera']").attr("id","shop['"+num+"'].businessOpera").attr("name","shop['"+num+"'].businessOpera");
17         $(this).find("input[name='shop[0].businessAddress']").attr("id","shop['"+num+"'].businessAddress").attr("name","shop['"+num+"'].businessAddress");
18         $(this).find("input[name='shop[0].warehouseAddress']").attr("id","shop['"+num+"'].warehouseAddress").attr("name","shop['"+num+"'].warehouseAddress");
19         $(this).find("input[name='shop[0].salesIncome']").attr("id","shop['"+num+"'].salesIncome").attr("name","shop['"+num+"'].salesIncome");
20         $(this).find("input[name='shop[0].totalLiability']").attr("id","shop['"+num+"'].totalLiability").attr("name","shop['"+num+"'].totalLiability");
21         $(this).find("input[name='shop[0].bankLiabilities']").attr("id","shop['"+num+"'].bankLiabilities").attr("name","shop['"+num+"'].bankLiabilities");
22         $(this).find("input[name='shop[0].netProfit']").attr("id","shop['"+num+"'].netProfit").attr("name","shop['"+num+"'].netProfit");
23     });
24     $('#rowCount').val(num);//重新賦值
25 }  
26 //刪除行  
27 function delShopRow(){  
28     var num=$("#rowCount").val();//取值
29     num=parseInt(num);
30     if(num>0){
31         $("#tShopRow"+num).remove();
32         num--;
33          $('#rowCount').val(num);//重新賦值
34     }else{
35         alert("這是第一行了!");
36     }
37     
38 }
javaScript

 

第二種方式:

spring Mvc控制器入口:

 1 public void save(HttpServletRequest request,HttpServletResponse response) throws Exception{
 2         BusLoanInfoGuaranter busLoanInfoGuaranter=new BusLoanInfoGuaranter();
 3                 busLoanInfoGuaranter.setBid(busLoanInfo.getId());
 4                 busLoanInfoGuaranter.setGuaranterName(request.getParameter("guaranterName"+i));
 5                 busLoanInfoGuaranter.setGuaranterCard(request.getParameter("guaranterCard"+i));
 6                 busLoanInfoGuaranter.setGuaranterEmployer(request.getParameter("guaranterEmployer"+i));
 7                 busLoanInfoGuaranter.setGuaranterDuties(request.getParameter("guaranterDuties"+i));
 8                 busLoanInfoGuaranter.setGuaranterPhone(request.getParameter("guaranterPhone"+i));
 9                 busLoanInfoGuaranter.setGuaranterMaritalStatus(request.getParameter("guaranterMaritalStatus"+i));
10                 busLoanInfoGuaranter.setGuaranterHouseAddress(request.getParameter("guaranterHouseAddress"+i));
11                 busLoanInfoGuaranter.setGuaranterMonthlyIncome(request.getParameter("guaranterMonthlyIncome"+i));
12                 busLoanInfoGuaranter.setGuaranterValues(request.getParameter("guaranterValues"+i));
13                 busLoanInfoGuaranter.setGuaranterTotalLiabilities(request.getParameter("guaranterTotalLiabilities"+i));
14 }
spring Mvc訪問入口

htm代碼:

 1 <div class="ftitle">是否提供自然人保證,是就填寫下麵信息</div>
 2                         <div class="fitem">  
 3                            <label class="ui-label">是否提供自然人保證:</label><select class="easyui-combobox" name="ifGuaranter" style="width:139px">
 4                                 <option value=""></option>
 5                                 <option value="是"></option>
 6                                 <option value="否"></option>
 7                             </select>
 8                        </div>
 9                        
10                        <div class="ftitle">保證人信息</div>
11                         <div class="fitem">  
12                               <table id="tblData">
13                                   <tr>
14                                       <td>保證人姓名</td>
15                                       <td>證件號碼</td>
16                                       <td>工作單位</td>
17                                       <td>職務</td>
18                                       <td>聯繫電話</td>
19                                       <td>婚姻狀況</td>
20                                       <td>家庭地址</td>
21                                       <td>月收入情況</td>
22                                       <td>資產總額</td>
23                                       <td>負債總額</td>
24                                   </tr>
25                                   <tr id="tRow0">
26                                       <td>
27                                       <input type="text" id="guaranterName0" name="guaranterName0" style="width:89px">
28                                       </td>
29                                       <td>
30                                       <input  type="text" id="guaranterCard0"  name="guaranterCard0" style="width:89px">
31                                       </td

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 有不足之處,請大家指出 一、 基礎知識 1、SDK的最新下載 搜索oracle,進入網站,à Downloads –> JavaSEI à 選第一個下載(其實java 8u111和8u112的區別就是在8u111的基礎上優化了一下,升了下級,實際使用沒什麼區別的) 其次註意一下選32位還是64位,是 ...
  • 無限級分類是一種設計技巧,在開發中經常使用,例如:網站目錄、部門結構、文章分類。筆者覺得它在對於設計表的層級結構上面發揮很大的作用,比如大家在一些平臺上面, 填寫邀請人,它就是一種上下級的關係,上級會有多個下級,下級又會有自己的分支,大多數都是利用遞歸的思想去實現。話不多說,首先來溫故一下遞歸的實現 ...
  • 如果你還沒有搭建gtest框架,可以參考我之前的博客:http://www.cnblogs.com/jycboy/p/6001153.html。。 1.The first sample: sample1 你把github上的項目導來之後,github地址:https://github.com/goo ...
  • RPC即遠程過程調用,它的實現方式有很多,比如webservice等。框架調多了,煩了,沒激情了,我們就該問自己,這些框架的作用到底是什麼,來找回當初的激情。 一般來說,我們寫的系統就是一個單機系統,一個web伺服器一個資料庫服務,但是當這單台伺服器的處理能力受硬體成本的限制,是不能無限的提升處理性 ...
  • 一、設置一個新的測試項目 在用google test寫測試項目之前,需要先編譯gtest到library庫並將測試與其鏈接。我們為一些流行的構建系統提供了構建文件: msvc/ for Visual Studio, xcode/ for Mac Xcode, make/ for GNU make,  ...
  • 背景說明 最近在工作項目中有下麵一個場景: 使用Node.js的express框架實現了一個文件系統伺服器端,其中有個API用於客戶端上傳文件。客戶端使用Node.js的HttpClient來調用伺服器端的API上傳文件。 客戶端在上傳小文件時沒有任何問題,在上傳大文件時httpClient請求報錯 ...
  • wordpress是用php語言開發的博客平臺,它擴展性強,容易擴展,很適合拿來做二次開發。 1,問題由來 本周五,我在瀏覽公司的網站(基於wordpress開發)時發現,網站首頁上有兩篇文章的縮略圖重覆了,於是我進入網站後臺檢查,想看下是不是某位員工在撰寫文章時不小心這兩篇文章選擇了相同的圖片作為 ...
  • CREATESTRUCT結構CREATESTRUCT結構具有如下形式:typedef struct tagCREATESTRUCT{ LPVOID lpCreateParams; HANDLE hInstance; HMENU hMenu; HWND hwndParent; int cy; int ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...