将来自REST调用的@PathParam值存储在列表或数组中(Store @PathParam values from REST call in a list or array)
我的功能如下所示:
@PUT @Path("property/{uuid}/{key}/{value}") @Produces("application/xml") public Map<String,ValueEntity> updateProperty(@Context HttpServletRequest request, @PathParam("key") String key, @PathParam("value") String value, @PathParam("uuid") String uuid) throws Exception { ... }
我必须修改它,所以它接受来自REST调用的键 - 值对的不确定(或许多)列表,类似
@Path("property/{uuid}/{key1}/{value1}/{key2}/{value2}/{key3}/{value3}/...")
是否有可能将它们存储在数组或列表中,因此我不会列出数十个@PathParams和参数,以避免这种情况:
@PathParam("key1") String key1, @PathParam("key2") String key2, @PathParam("key3") String key3,
My function looks like this:
@PUT @Path("property/{uuid}/{key}/{value}") @Produces("application/xml") public Map<String,ValueEntity> updateProperty(@Context HttpServletRequest request, @PathParam("key") String key, @PathParam("value") String value, @PathParam("uuid") String uuid) throws Exception { ... }
I have to modify it, so it accepts indefinite(or many) list of key-value pairs from REST call, something like
@Path("property/{uuid}/{key1}/{value1}/{key2}/{value2}/{key3}/{value3}/...")
Is it possible to store them in an array or list, so I do not list dozens of @PathParams and parameters, to avoid this:
@PathParam("key1") String key1, @PathParam("key2") String key2, @PathParam("key3") String key3,
原文:https://stackoverflow.com/questions/26992222
最满意答案
你有这个声明
static NSInteger *previousPage = 0;
在你的代码中,它声明
previousPage
是一个指向一个整数(而不是一个整数)的指针,并将它初始化为null
指针(而不是零值0
)。在
if(previousPage != page){ //page has changed previousPage = page; }
您将
previousPage
的指针值与page
的整数值进行比较,从而发现错误。 在previousPage
的声明中简单地删除*
。static NSInteger previousPage = 0;
You have the declaration
static NSInteger *previousPage = 0;
in your code, which declares
previousPage
to be a pointer to an integer (not an integer), and initializes it to thenull
pointer (not the value0
zero).In
if(previousPage != page){ //page has changed previousPage = page; }
you compare the pointer value of
previousPage
to the integer value ofpage
, hence the error. Simple drop the*
in the declaration ofpreviousPage
.static NSInteger previousPage = 0;
相关问答
更多-
你将我声明为指针: int *i = 0 。 应该是int i = 0 。 You're declaring i as a pointer: int *i = 0. Should be int i = 0.
-
你有这个声明 static NSInteger *previousPage = 0; 在你的代码中,它声明previousPage是一个指向一个整数(而不是一个整数)的指针,并将它初始化为null指针(而不是零值0 )。 在 if(previousPage != page){ //page has changed previousPage = page; } 您将previousPage的指针值与page的整数值进行比较,从而发现错误。 在previousPage的声明中简单地删除* 。 st ...
-
尽管问题中缺少大量信息,但我的通灵能力告诉我问题是NSArray类的消息-objectAtIndex:返回类型为id的通用对象。 因此,表达式[[_tempPostalCodeList objectAtIndex:i] postalCode]正在将postalCode消息发送到id类型的对象。 由于编译器不知道实际对象的基础类型,因此无法推断出postalCode消息的返回类型,因此它假定它也返回id 。 id是一个指针类型,由于postalCode是一个整数类型,编译器认为你在评估==运算符时会尝试将指针 ...
-
NULL是一个指针, str[i]是str数组的第i个字符。 char是整数类型,当你比较它们时,你会得到警告。 我想你想检查字符串的结尾,你会用值0(字符串结尾),即'\0'检查char。 但是:这不会帮助你,因为你将它定义为字符数组而不是字符串,并且你没有在char数组中定义终止0(你很幸运,它隐含在那里)。 PS:下次您应该至少提供编译器抱怨的信息。 NULL is a pointer and str[i] is the i-th char of the str array. char is and ...
-
由于你的menuType是一个指向枚举值的指针,你可以重写你的条件: if (*(menuItem.menuType) == LinkExternal) 但为什么你需要通过指针来存储这个值? 你不能只是: enum menuItemType menuType; As your menuType is a pointer to enum value you can rewrite your condition: if (*(menuItem.menuType) == LinkExternal) But ...
-
那么你只能比较本质上具有可比性的东西。 整数和地址太不同了,无法比较; 整数是值,而地址是指向值的指针,它们的用法太不同了,不能将它们视为可比较的。 NULL被定义为((void *)0) ,它是一个指针的特殊常量,它表示一个永远不会指向某个东西的指针......它被指定为一个指针。 void *是指针的通用类型。 \1是char的常量(它是ASCII表中索引1的字符,它被称为SOH char)。 字符大致是一个数字,打印时可以很容易地转换为字符。 你的字面量是1类型的字符,但为了提高效率,在几乎所有的算术 ...
-
C将char与“\ n”警告进行比较:指针和整数之间的比较(C comparing char to “\n” warning: comparison between pointer and integer)[2022-10-31]
\n'被称为字符文字,是标量整数类型。 "\n"被称为字符串文字,是一种数组类型。 请注意,数组会衰减为指针,因此这就是您收到该错误的原因。 这可能有助于您理解: // analogous to using '\n' char c; int n = 0; while ( (c = getchar()) != EOF ){ int comparison_value = 10; // 10 is \n in ascii encoding if (c == comparison_value){ ... -
循环跳过getchar和指针与整数之间的比较(While Loop Skipping Over getchar and Comparison Between Pointer and Integer)[2023-07-04]
首先,我假设您在第1行中使用“#include”而不是“import”,并在第12行中使用“answer”而不是“a”。 要回答你的实际问题,在C char和string中是不同的。 你有一个char类型的变量答案,你正在与字符串“u”进行比较。 因此,编译器正在创建一个常量字符串“u”,并将指向该字符串的指针与char类型变量answer进行比较。 你的支票应该有 if(answer == 'u') { First of all, I am assuming you have "#include" in ... -
NULL是一个定义空指针常量的宏,而不是ASCII字符NUL。 如果你想测试一个角色NUL,那么: if( **p == '\0' ) 或更简单地说: if( **p == 0 ) NULL is a macro defining a null-pointer constant, not the ASCII character NUL. If you want to test for a character NUL, then: if( **p == '\0' ) or more simply: if ...
-
self.myCalType在哪里定义? 我只是复制了你的代码并重新运行 - 这里没有警告,所以我猜你可能做了类似的事情: @property NSInteger *myCalType; 代替 @property NSInteger myCalType; Where is self.myCalType defined? I just copied your code and re-ran - no warnings here, so I'm guessing you possibly did somethi ...