NutzCN Logo
问答 int 类型参数赋string类型的值,怎么在调取方法时提前过滤校验
发布于 2282天前 作者 qq_ec453099 1830 次浏览 复制 上一个帖子 下一个帖子
标签:

@At("/saveStudent")
//@Aop("validationInterceptor")
public Messages saveStudent(@Param("age")int age,@Param("..")Student student, Errors es) {
return studentService.addStudent(student,es);
}

15 回复

@Filters(@By(type=EnterFilter.class, args= {"ioc:enterFilter"}))
public class EnterFilter implements ActionFilter{
public View match(ActionContext actionContext) {
HttpServletRequest request = actionContext.getRequest();
String paramStr = request.getQueryString();
return null;
}

写了个filter,能拿到所有参数,但怎么拿到public Messages saveStudent(@Param("age")int age,@Param("..")Student student, Errors es) {} 这个方法的参数类型;拿到比较参数类型

动作链加个处理器

Object[] objects = ac.getMethodArgs();
为什么objects == null ,获取不到参数

需要放在AdapterProcessor之后

动作链中 处理器,怎么返回数据,例如json数据

ac.getResp然后为所欲为

在AdaptorProcessor 之前加了个处理器,我要拿到所有参数、然后和被调用方法的参数类型比对;过滤掉参数类型不匹配的参数值;
但我能拿到调用方法saveStudent(@Param("age")int age,@Param("..")Student student, Errors es)的参数类型、method.getParameterTypes() ,
对象类型的参数(student),我反射能拿到参数及类型;但int age 这个我拿不到参数名,怎么做age参数的类型匹配,我要怎么做?

ActionInfo实例里面有paramNames

ActionInfo 么有个paramNames

你用的啥版本?

62是有的啊

62么,我升版本,可以了

添加回复
请先登陆
回到顶部