2013-12-13 1113 views
1

我正在使用HandlerInterceptor觸發在我的應用程序中發生的所有事件/操作,並將它保存到審計表。在表中我保存的信息,如服務器名稱,會話,參數等。如何讀取請求參數值在Spring中使用HandlerInterceptor?

因此,使用HandlerInterceptor如何讀取所有這些參數值和路徑變量值我在我的控制器中傳遞。

這裏是我的代碼:

public class AuditInterceptor implements HandlerInterceptor { 

    @Override 
    public boolean preHandle(HttpServletRequest request, 
      HttpServletResponse response, Object handler) throws Exception { 
      LOG.debug("URL path"+request.getRequestURI()); 
       return true; 
    } 

    @Override 
    public void postHandle(HttpServletRequest request, 
      HttpServletResponse response, Object handler, 
      ModelAndView modelAndView) throws Exception { 
     LOG.debug("URL PATH :"+request.getRequestURI()); 

    } 

} 

我的控制器類在這裏輸入的代碼::

public class ABCDController { 
@RequestMapping(value="categories",method=RequestMethod.GET) 
    @ResponseBody 
    public List<Category> getCategoryList(@RequestParam String divisions){ 
     return service.getCategoryList(divisions); 
    } 
} 

因此,如何能讀我使用的HandlerInterceptor的HttpServletRequest的請求對象中的參數名稱和值。

回答

相關問題