springmvc 拦截器 怎么获取方法的参数值
controller 方法
@RequestMapping(value="login" , method=RequestMethod.POST)
public void login(String username , String password){
userService.login(username, password) ;
}
拦截器代码
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
HandlerMethod handlerMethod = (HandlerMethod) handler;
for (MethodParameter methodParameter : handlerMethod.getMethodParameters()) {
methodParameter.getParameterName();
//怎么获取参数值?获取username 和password
}
return true;
}
bthlon
10 years, 9 months ago