當前位置: 首頁>>代碼示例>>Java>>正文


Java WebUtils.saveRequest方法代碼示例

本文整理匯總了Java中org.apache.shiro.web.util.WebUtils.saveRequest方法的典型用法代碼示例。如果您正苦於以下問題:Java WebUtils.saveRequest方法的具體用法?Java WebUtils.saveRequest怎麽用?Java WebUtils.saveRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.shiro.web.util.WebUtils的用法示例。


在下文中一共展示了WebUtils.saveRequest方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: redirectLogin

import org.apache.shiro.web.util.WebUtils; //導入方法依賴的package包/類
protected void redirectLogin(ServletRequest request, ServletResponse response) throws IOException {
      WebUtils.saveRequest(request);
      String path = WebUtils.getContextPath((HttpServletRequest) request);
      String url = loginUrl;
      if (StringUtils.isNotBlank(path) && path.length() > 1) {
      	url = path + url;
}
      
      if (isAjaxRequest((HttpServletRequest) request)) {
      	response.setContentType("application/json;charset=UTF-8");
	Gson gson = new Gson();
	response.getWriter().print(gson.toJson(Data.failure("您還沒有登錄!")));
      } else {
      	response.getWriter().write(new Formatter().format(JS, url).toString());
      }
  }
 
開發者ID:ThomasYangZi,項目名稱:mblog,代碼行數:17,代碼來源:AuthenticatedFilter.java

示例2: onAccessDenied

import org.apache.shiro.web.util.WebUtils; //導入方法依賴的package包/類
@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
	log.debug("username[{}] SimpleAuthFilter denied,未登陸,跳轉到登陸頁麵");
	Subject subject = SecurityUtils.getSubject();
	subject.logout();
	/**
	 * 保存Request,用來保存當前Request,然後登錄後可以跳轉到當前瀏覽的頁麵. 比如:
	 * 我要訪問一個URL地址,/admin/index.html,這個頁麵是要登錄.然後要跳轉到登錄頁麵,但是登錄後要跳轉回來到/admin/
	 * index.html這個地址,怎麽辦?
	 * 傳統的解決方法是變成/user/login.shtml?redirectUrl=/admin/index.html.
	 * shiro的解決辦法不是這樣的.需要:<code>WebUtils.getSavedRequest(request);</code>
	 * 然後:{@link UserLoginController.submitLogin(...)}中的
	 * <code>String url = WebUtils.getSavedRequest(request).getRequestUrl();</code>
	 */
	WebUtils.saveRequest(request);
	// 再重定向
	WebUtils.issueRedirect(request, response, "/toLogin.htm");
	return false;
}
 
開發者ID:ls960972314,項目名稱:report,代碼行數:20,代碼來源:SimpleAuthFilter.java

示例3: unauthenticated

import org.apache.shiro.web.util.WebUtils; //導入方法依賴的package包/類
@ExceptionHandler(value = {UnauthenticatedException.class})
public RedirectView unauthenticated(WebRequest request) {
    // @RequiresUser등으로 로그인으로 강제 전환이 이루어질때, 다시 돌아올 위치를 저장.
    if (request instanceof ServletWebRequest) {
        ServletWebRequest swr = (ServletWebRequest) request;
        if (swr.getRequest() != null) {
            // NOTE: ...이거 이외에도 ㅎㅎㅎ 페이지들 jsp으로 그대로 redirect해버림.
            final String s = ObjectUtils.toString(swr.getRequest().getRequestURL());
            if (false == (s.startsWith("/WEB-INF/") && s.endsWith(".jsp"))) {
                LOG.debug(String.format("SAVE REQUEST FOR LOGIN-SUCCESS-REDIRECT = [%s]", swr.getRequest().getRequestURL()));
                WebUtils.saveRequest(swr.getRequest());
            }
        }
    }
    return new RedirectView(String.format("%s/a/error/unauthenticated", WebappPath.getWebappPath()));
}
 
開發者ID:ageldama,項目名稱:glados-wiki,代碼行數:17,代碼來源:ErrorController.java

示例4: saveRequest

import org.apache.shiro.web.util.WebUtils; //導入方法依賴的package包/類
/**
 * Convenience method merely delegates to
 * {@link WebUtils#saveRequest(javax.servlet.ServletRequest) WebUtils.saveRequest(request)} to save the request
 * state for reuse later.  This is mostly used to retain user request state when a redirect is issued to
 * return the user to their originally requested url/resource.
 * <p/>
 * If you need to save and then immediately redirect the user to login, consider using
 * {@link #saveRequestAndRedirectToLogin(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
 * saveRequestAndRedirectToLogin(request,response)} directly.
 *
 * @param request the incoming ServletRequest to save for re-use later (for example, after a redirect).
 */
protected void saveRequest(ServletRequest request) {
    WebUtils.saveRequest(request);
}
 
開發者ID:xuegongzi,項目名稱:rabbitframework,代碼行數:16,代碼來源:AccessControlFilter.java


注:本文中的org.apache.shiro.web.util.WebUtils.saveRequest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。