如何检索Java中的数组值? [英] How to retrieve Array values in Java?
问题描述
在我的Java应用程序中,我得到了像Array这样的Request参数。
< script type =text / javascript> ;
var names = new Array(); $ b $ .ajax({
url:Result,
type:'POST',
data:{
names:JSON.stringify(names) ,
globalClassId:globalClassId
}});
< / script>
现在我在java中获取这个请求参数并正确地检索值。
//获取每个添加的用户名称[]
for(String id:names){
--- -
-----
}
但是在java边我'获取值 如何删除这个额外的括号在我的字符串 请帮我解释一下它们在Array中的错误声明。我们可以使用names.join(),这将返回。 数组, 所以我们ca ñ轻松发送请求属性,如字符串 现在使用循环我们很容易得到像.. .. In my Java Application i'm getting Request parameter like Array Now i'm getting this request parameter in java and retrieve the values correctly.. But in java side i'm getting values if we pass this value to database for example select query,But it is giving null value.. even we pass correct value but we are getting null value. How to remove this extra brackets in my String Please help me is their any wrong declaration in Array. instead of so we can easily send request attribute like string and now using for loop we easily get values like..
这篇关于如何检索Java中的数组值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! names = [[1000]]
,并在for循环中获得 id = [value1] $如果我们把这个值传递给数据库,例如选择查询,但它给出了空值。即使我们传递正确的值,但我们得到空值。
[1000]
这是原始值,但我想只有 1000
。
@RequestParam(names)字符串名称
$ $ p $ //获取每个添加的用户使用名称[
for(String id: names.split(,)){
----------
}
<script type="text/javascript">
var names = new Array();
$.ajax({
url : "Result",
type : 'POST',
data : {
"names" : JSON.stringify(names),
"globalClassId" : globalClassId
}});
</script>
//Get the each added user using names[]
for (String id : names) {
-----
-----
}
names=[["1000"]]
and in for loop i'm getting id=["value1"]
["1000"]
this is original value but i want only 1000
.JSON.stringify(names)
we can use names.join() this will be return Array,@RequestParam("names") String names
//Get the each added user using names[]
for (String id : names.split(",")) {
----------
}