我想创建自定义注释(例如@ValidAddress
),它将验证对象(使用与JSR303无关的自定义逻辑)并在值无效的情况下抛出异常:
public Response registerAddress(@ValidAddress Address address)
使用javax.validation.Constraint
和javax.validation.ConstraintValidator
(sample)很容易实现,但它有一些奇怪的限制:
message
/ groups
/ payload
参数问题:
如何添加自定义注释,该注释将在myFunction($param)
从正文中反序列化$param
的请求中执行#include<fcntl.h>
#include<unistd.h>
#include<stdio.h>
...
int main(int argc, char * argv[])
{
int cp_from = open(argv[1],O_WRONLY);
int cp_to = open(argv[2],O_WRONLY|O_CREAT,0777); //make a descriptor for each file
int size = lseek(cp_from,0,SEEK_END); //check the size of the first file
lseek(cp_from,0,SEEK_SET) //return to the start of the file, don't know if that's needed
char *buf = (char*) malloc (size*sizeof(char)); //allocate enough memory to fit all text from 1st file into char array
read(cp_from,buf,sizeof(buf)-1); //read from the 1st file to the char array
printf("%s",buf); //print the buf
close(cp_from);
close(cp_to);
...