스프링 mvc 및 스프링 보안을 기반으로하는 응용 프로그램에서 컨트롤러를 구성하는 데 @Controller
주석을 사용하고 있습니다.Spring 인터셉터 preHandle 메서드에서 컨트롤러 메서드 이름을 얻는 방법
스프링 핸들러 인터셉터과 preHandle()
메서드에서 인터셉터가 호출 할 메서드 이름을 얻고 싶습니다.
preHandle()
메서드에서 컨트롤러 메서드에 정의 된 사용자 지정 주석을 HandlerInterceptor
메서드로 가져와 해당 특정 메서드에 대한 작업을 로깅하여 관리 할 수 있습니다.
@Controller
public class ConsoleUserManagementController{
@RequestMapping(value = CONSOLE_NAMESPACE + "/account/changePassword.do", method = RequestMethod.GET)
@doLog(true)
public ModelAndView showChangePasswordPage() {
String returnView = USERMANAGEMENT_NAMESPACE + "/account/ChangePassword";
ModelAndView mavChangePassword = new ModelAndView(returnView);
LogUtils.logInfo("Getting Change Password service prerequisit attributes");
mavChangePassword.getModelMap().put("passwordModel", new PasswordModel());
return mavChangePassword;
}
}
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// here I want the controller method name(i.e showChangePasswordPage()
// for /account/changePassword.do url) to be called and that method annotation
// (i.e doLog()) so that by viewing annotation , I can manage whether for that
// particular controller method, whether to enable logging or not.
}
내가
당신은 그것을 다음과 같은 방법을 수행 체크 했습니까? –