亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

使用spring MVC將文件夾上傳到mysql時出錯

使用spring MVC將文件夾上傳到mysql時出錯

慕尼黑的夜晚無繁華 2021-05-30 12:52:32
我正在構建一個應用程序。用戶將查看一個頁面,用戶應輸入患者代碼和以下描述,然后用戶將上傳包含 CSV 文件的文件夾。我正在嘗試使用 spring MVC - JSP 上傳“由 CSV 文件組成的文件夾”(不是 zip/rar 文件)這是我的 JSP 代碼:<div class="w3-row w3-section">                        <div class="w3-col" style="width:200px">* Patient code</div>                        <div class="w3-rest">                            <%--<form:select path="patient">--%>                                <%--<form:options items="${patient}" itemLabel="name" itemValue="id"/>--%>                            <%--</form:select>--%>                                <form:input type="text" path="id_patient" name="id_patient" id="id_patient" placeholder="input number 1-20" class="w3-input w3-border"/>                        </div>                    </div>                    <div class="w3-row w3-section">                        <div class="w3-col" style="width:200px">* Patient description</div>                        <div class="w3-rest">                            <form:input type="text" path="description" name="description" id="description" placeholder="put any description" class="w3-input w3-border"/>                        </div>                    </div>                    <div class="w3-row w3-section">                        <div class="w3-col" style="width:200px">* Input Data Files</div>                        <div class="w3-rest">                            <input type="file" path="fileName" name="attachFileObj" webkitdirectory directory />                        </div>                    </div>這是我的 Patient.java 文件:public class Patient {    //field patient    private int id_patient;    private String description;    private String patient;    public String getDescription() {        return description;    }    public void setDescription(String description) {        this.description = description;    }    public int getId_patient() {        return id_patient;    }    public void setId_patient(int id_patient) {        this.id_patient = id_patient;    }
查看完整描述

2 回答

?
倚天杖

TA貢獻1828條經驗 獲得超3個贊

我認為您不能同時運行這兩個:


if(null != jdbcTemplate) {

            // Performing The Sql 'Insert' Operation

            String sql = "insert into patient(id_patient, description) values(?,?);" +

                    "insert into attachment(id_data, file_data, patientID) values (?, ?, (select patientID from patient where patientID = id_patient));";



            jdbcTemplate.update(sql, patient.getDescription(), attachment.getId_data(), attachment.getData(), attachment.getPatientID());

也許嘗試:


    if(null != jdbcTemplate) {

                // Performing The Sql 'Insert' Operation

                String sql = "insert into patient(id_patient, description) values(?,?);"; 


                String sqlTwo = "insert into attachment(id_data, file_data, patientID) values (?, ?, (select patientID from patient where patientID = id_patient));";



jdbcTemplate.update(sql, patient.getDescription(), attachment.getId_data(), attachment.getData(), attachment.getPatientID());


jdbcTemplate.update(sqlTwo, patient.getDescription(), attachment.getId_data(), attachment.getData(), attachment.getPatientID());


您不能使用嵌套子查詢綁定參數:


values (?, ?, (select patientID from patient where patientID = id_patient))


查看完整回答
反對 回復 2021-06-02
  • 2 回答
  • 0 關注
  • 198 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號