第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

一個(gè)jsp頁面混合添加了4張數(shù)據(jù)表中的數(shù)據(jù),提交到后臺之后,怎么分別處理并存儲到 對應(yīng)的庫表中呢?

一個(gè)jsp頁面混合添加了4張數(shù)據(jù)表中的數(shù)據(jù),提交到后臺之后,怎么分別處理并存儲到 對應(yīng)的庫表中呢?

猛跑小豬 2019-03-01 10:35:59
1.我的功能需求是:"問卷調(diào)查" , 庫表有三張,一個(gè)存問卷調(diào)查的標(biāo)題,一個(gè)存儲問卷調(diào)查的題目,一個(gè)是存問卷調(diào)查的題目對應(yīng)的選項(xiàng).2.個(gè)人難題: 如何將標(biāo)題,題目和選項(xiàng)通過一個(gè)jsp頁面存到三張庫表中.3.存題目的表和存選項(xiàng)的表是1對多的關(guān)系
查看完整描述

3 回答

?
料青山看我應(yīng)如是

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊

baidu google

查看完整回答
反對 回復(fù) 2019-03-01
?
HUWWW

TA貢獻(xiàn)1874條經(jīng)驗(yàn) 獲得超12個(gè)贊

form表單提交,后臺用實(shí)體接收的方式,有點(diǎn)繁瑣
我當(dāng)時(shí)是前臺將數(shù)據(jù)拼成json,轉(zhuǎn)換成字符串傳到后臺;
后臺解析為json對象,然后存儲對應(yīng)字段到對應(yīng)的表中

查看完整回答
反對 回復(fù) 2019-03-01
?
尚方寶劍之說

TA貢獻(xiàn)1788條經(jīng)驗(yàn) 獲得超4個(gè)贊

假設(shè)你的html如下:

<div class="content">
    <div class="title">
        <span>標(biāo)題:</span><input type="text" class="title"/>
    </div>
    <div class="list">
        <div class="item">
            <span>題目:</span><input type="text" class="question"/>
            <span>選項(xiàng):</span><input type="text" class="option"/>
            <span>選項(xiàng):</span><input type="text" class="option"/>
            <span>選項(xiàng):</span><input type="text" class="option"/>
            <span>選項(xiàng):</span><input type="text" class="option"/>
        </div>
        <div class="item">
            <span>題目:</span><input type="text" class="question"/>
            <span>選項(xiàng):</span><input type="text" class="option"/>
            <span>選項(xiàng):</span><input type="text" class="option"/>
            <span>選項(xiàng):</span><input type="text" class="option"/>
            <span>選項(xiàng):</span><input type="text" class="option"/>
        </div>
    </div>
</div>

你可以用js或者jquery,將問卷當(dāng)做一個(gè)js對象,然后格式化為json字符串進(jìn)行傳輸。

<script type="text/javascript">
    var title = $('.content .title input').val();
    // 獲取<div class='item'>標(biāo)簽數(shù)組
    var itemList = $('.content div.list').children();
    var itemArray = [];
    for (int i = 0; i < itemList.length; i++) {
        var question = itemList[i].class('.question').val();
        var options = [];
        itemList.class('option').each(function(index, value){
               options.push($(this).val());
        });
        itemArray.push({question: question, option: options});
    }
    // 得到的對象格式形如:
    /*{
        title: "title",
        question: [
            {
                question: "Which kind of animal do you like most?",
                option: ["horse", "koala", "rabbit", "panda"]
            },
            {
                question: "Which kind of animal do you like most?",
                option: ["horse", "koala", "rabbit", "panda"]
            }
        ]
    }*/
    var combinedParam = {title: title, question: itemArray};
    // 將combinedParam轉(zhuǎn)為JSON字符串傳給后臺
    // ...
</script>

我不懂js所以以上的代碼你權(quán)當(dāng)偽代碼看。
java端獲取JSON字符串以后,反序列化得到JSON對象,然后根據(jù)需要,該怎么存表就怎么存。

查看完整回答
反對 回復(fù) 2019-03-01
?
蝴蝶刀刀

TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超8個(gè)贊

用js或者ajax實(shí)現(xiàn),點(diǎn)擊一個(gè)按鈕,觸發(fā)三個(gè)函數(shù)或者ajax

查看完整回答
反對 回復(fù) 2019-03-01
  • 3 回答
  • 0 關(guān)注
  • 721 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號