如何将List 传递给api url?(How can I pass a List to an api url?)
假设我在
MyAPIS
控制器中有这样的api方法:public List<string> GetList(List<string> myList) { var newList = myList; return newList; }
uri绑定到这个动作应该像mysite / api / myapis / getlist / [id]。 通常id是单个值而不是复杂项。
但是你怎么能设法像这样的网址呢?Suppose I have an api method like this inside
MyAPIS
controller:public List<string> GetList(List<string> myList) { var newList = myList; return newList; }
The uri bind to this action should be something like mysite/api/myapis/getlist/[id]. Usually the id is a single value and not a complex item.
But how'd you manage to arrage an url like this?
原文:https://stackoverflow.com/questions/20571567
更新时间:2022-05-29 07:05
最满意答案
Try this : String axis="x=-0.125 y=0.9375 z=0.375"; String[] tempArr=axis.split(" "); ArrayList arr=new ArrayList<String>(); for(String a:tempArr){ arr.add(a.split("=")[1].trim()); } System.out.println(arr);
这将分配x,y和z的所有值
Try this : String axis="x=-0.125 y=0.9375 z=0.375"; String[] tempArr=axis.split(" "); ArrayList arr=new ArrayList<String>(); for(String a:tempArr){ arr.add(a.split("=")[1].trim()); } System.out.println(arr);
this will sperate the all the values of x,y&z
相关问答
更多-
String string = "AA|BB|CC"; String[] arr = string.split("\\|"); for (String s : arr) { System.out.println(s); } 上面的代码打印: AA BB CC String string = "AA|BB|CC"; String[] arr = string.split("\\|"); for (String s : arr) { System.out.println(s); } The ...
-
Java - 拆分字符串?(Java - Split a String?)[2023-08-04]
您的示例将无法编译,因为您的myString变量中有未转义的双引号。 但是,假设它被逃脱... // | escaped " here String myString = "Hello Boom, Ho3w are || You ? Are ^ you ,\" fr45ee now ?"; // | printing array // ... -
此行为在String.split(String regex) (强调我的)中明确记录: 该方法的工作原理是通过使用给定的表达式和极限参数为零调用双参数拆分方法。 因此, 尾随的空字符串 不会包含在结果数组中。 如果您希望包含尾随的空字符串,则需要对第二个参数( limit )使用负值的String.split(String regex, int limit) limit ): String[] array = values.split("\\|", -1); This behavior is explic ...
-
split(delimiter)默认从结果数组中删除尾随的空字符串。 要关闭此机制,我们需要使用limit设置为负值的split(delimiter, limit)重载版本 String[] split = data.split("\\|", -1); 更多细节: split(regex)内部返回split(regex, 0)结果,并且在这种方法的文档中可以找到(强调我的) limit参数控制模式应用的次数,因此影响生成的数组的长度。 如果极限n 大于0,则模式将最多施加n次,数组长度不大于n,数组的最后 ...
-
如何在java中拆分字符串\(how to Split String By \ in java)[2022-02-19]
One\Two\Three不是有效的字符串文字(你需要引号,你需要转义反斜杠)。 String name = "One\\Two\\Three."; String[] str = name.split("\\\\"); for(int i =0; i < str.length ; i++) System.out.println(str[i]); 工作正常 。 说明 String#split需要正则表达式。 反斜杠字符在正则表达式中具有特殊含义,因此您需要使用另一个反斜杠来转义它: \\现在因为反斜杠 ... -
您是否尝试通过Split运行它,并将regex参数设置为"[\\[\\]\\', ]" 基本上任何[ , ] ,,, ' , - 更多信息在这里 Have you tried running it through Split with the regex parameter as"[\\[\\]\\', ]" Basically any of [,],,,', - more information here
-
Try this : String axis="x=-0.125 y=0.9375 z=0.375"; String[] tempArr=axis.split(" "); ArrayList arr=new ArrayList
(); for(String a:tempArr){ arr.add(a.split("=" ... -
您可以尝试以下正则表达式: (?:class="priceValue">\s*)(\d*\.\d+) 它查找class="priceValue"字符串,后跟价格 这是DEMO和解释 You can try following regex: (?:class="priceValue">\s*)(\d*\.\d+) It looks for a class="priceValue"string followed by a price Here is DEMO and explanation
-
适合我。 String in = "3:2 2:26 1:11 8:4 4:25"; String[] split = in.split(" "); int sum = 0; for(int i = 0; i < split.length; i++) { try { sum += Integer.parseInt(split[i].split(":")[1]); } catch(NumberFormatExce ...
-
拆分字符串Java空间(Split String Java Space)[2022-03-10]
在确定它存在之前,不要尝试访问数组中的第二个元素。 例: if(comando2.length < 1) { // the user typed only spaces } else { String first = comando2[0]; if(first.equalsIgnoreCase("exit")) { // or comando.equalsIgnoreCase("exit"), depending on whether the user is allowed to t ...