springmvc 拦截器 怎么获取方法的参数值(3.0.5以上的版本有 HandlerMethod)

springmvc 拦截器 怎么获取方法的参数值

    @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;
    }

转载: http://www.dewen.org/q/9586/springmvc+%E6%8B%A6%E6%88%AA%E5%99%A8+%E6%80%8E%E4%B9%88%E8%8E%B7%E5%8F%96%E6%96%B9%E6%B3%95%E7%9A%84%E5%8F%82%E6%95%B0%E5%80%BC

你可能感兴趣的:(spring)