HttpServletRequest request =
((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(request.getServletContext());
GroovyService groovyService = (GroovyService)webApplicationContext.getBean("GroovyService");
- 访问引发认证跳转到当前代码块,获取引发跳转的URL
RequestCache requestCache = new HttpSessionRequestCache();
SavedRequest savedRequest = requestCache.getRequest(request, response);
String targetUrl = savedRequest.getRedirectUrl();
RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
redirectStrategy.sendRedirect(request, response, "登陆页的url");
NativeWebRequest webRequest = new ServletWebRequest(request);
Map<String, String> pathVariableMap =
(Map<String, String>) webRequest.getAttribute(
HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE,
RequestAttributes.SCOPE_REQUEST);
String id = pathVariableMap .get("id"); //get id pathvariable form request
StackTraceElement[] stacks = (new Throwable()).getStackTrace();
for (StackTraceElement stack : stacks) {
System.out.println(stack.getClassName() + "-" + stack.getMethodName());
}
网友评论