gpt4 book ai didi

java - 如何将从 html 文本框接收到的字符串转换为数组,然后将其传输到存储过程?

转载 作者:行者123 更新时间:2023-12-02 09:42:01 25 4
gpt4 key购买 nike

我在文本框中收到字符串(例如:“Delhi,Mumbai,Kolkata”),然后将其发送到jsp页面,我需要将其转换为数组,以便数组的第一个元素具有“Delhi”,第二个有“孟买”等。现在我想将此数组发送到我的数据库处理程序页面,其中我有一个方法需要接收此字符串并使用此参数调用存储过程。基本上,我不确定如何将字符串转换为数组,然后将其传递给存储过程。任何帮助将不胜感激。谢谢。

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.java
public 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;
}

存储过程需要接收数组。

最佳答案

使用

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

这会将具有多个城市的字符串转换为城市字符串数组。

关于java - 如何将从 html 文本框接收到的字符串转换为数组,然后将其传输到存储过程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56993851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com