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

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

如何將從 html 文本框接收到的字符串轉換為數組,然后將其傳輸到存儲過程?

如何將從 html 文本框接收到的字符串轉換為數組,然后將其傳輸到存儲過程?

收到一只叮咚 2023-03-23 13:39:45
我在文本框中收到字符串(例如:“Delhi,Mumbai,Kolkata”),然后將其發送到 jsp 頁面,我需要將其轉換為數組,以便數組的第一個元素為“Delhi”,第二個元素為“孟買”等?,F在我想將這個數組發送到我的數據庫處理程序頁面,在那里我有一個方法需要接收這個字符串并使用這個參數調用存儲過程?;旧?,我不確定如何將字符串轉換為數組,然后將其傳遞給存儲過程。任何幫助將不勝感激。謝謝。This is my jsp code:String s_word= request.getParameter("Search_Word");            session.setAttribute("ssword", s_word);            String[] indnames = s_word.split(",");//Here i don't know how to send indnames to the dbhandler page.-----------------------------------------------------------------------My method in dbhandler.javapublic static ResultSet zz(String[] a) {        ResultSet rs=null;        try {            Connection con = getConnection();            CallableStatement ps = con.prepareCall("{call zz1(?,?)}");            ps.setArray(1,a);            ps.registerOutParameter(2, OracleTypes.CURSOR);            ps.execute();            rs = ((OracleCallableStatement) ps).getCursor(2);        } catch (Exception e) {        }        return rs;    }存儲過程需要接收數組。
查看完整描述

3 回答

?
交互式愛情

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

使用

String cities[] = stringVariable.split("");

這會將具有多個城市的字符串轉換為城市的字符串數組。


查看完整回答
反對 回復 2023-03-23
?
臨摹微笑

TA貢獻1982條經驗 獲得超2個贊

您可以將值傳遞給 java 類,如下所示,


<jsp:useBean id="sample" scope="page" class="com.mellon.sample" /> // sample is java file name  


//-------now pass parameter indnames to your sample java file here sample is the class name and function_name is the method name.


sample.function_name(indnames);


查看完整回答
反對 回復 2023-03-23
?
守著星空守著你

TA貢獻1799條經驗 獲得超8個贊

好吧,我知道它是怎么做到的。在 zz 方法下的 dbhandler.java 頁面中,我添加了:


Connection con = getConnection();

ArrayDescriptor arr= ArrayDescriptor.createDescriptor("ARRAY_COLLECTION",con);

//Here ARRAY_COLLECTION is my array type.

Array array= new ARRAY(arr,con,a);

//'a' is my String[] variable

Callable statement= con.prepareCall("{call zz1(?,?)}");

ps.setArray(1, array);

.

.

.

and so on.


查看完整回答
反對 回復 2023-03-23
  • 3 回答
  • 0 關注
  • 212 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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