本文整理汇总了Java中org.apache.shiro.web.util.WebUtils.redirectToSavedRequest方法的典型用法代码示例。如果您正苦于以下问题:Java WebUtils.redirectToSavedRequest方法的具体用法?Java WebUtils.redirectToSavedRequest怎么用?Java WebUtils.redirectToSavedRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.shiro.web.util.WebUtils
的用法示例。
在下文中一共展示了WebUtils.redirectToSavedRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: issueSuccessRedirect
import org.apache.shiro.web.util.WebUtils; //导入方法依赖的package包/类
protected void issueSuccessRedirect(ServletRequest request, ServletResponse response)
throws Exception {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
String successUrl = req.getParameter(RETURN_URL);
if (StringUtils.isBlank(successUrl)) {
if (req.getRequestURI().startsWith(
req.getContextPath() + getAdminPrefix())) {
// 后台直接返回首页
successUrl = getAdminIndex();
// 清除SavedRequest
WebUtils.getAndClearSavedRequest(request);
WebUtils.issueRedirect(request, response, successUrl, null,true);
return;
} else {
successUrl = getSuccessUrl();
}
}
WebUtils.redirectToSavedRequest(req, res, successUrl);
}
示例2: isAccessAllowed
import org.apache.shiro.web.util.WebUtils; //导入方法依赖的package包/类
@Override
protected boolean isAccessAllowed(ServletRequest request,
ServletResponse response, Object mappedValue) throws Exception {
System.out.println("access allowed");
saveRequest(request);
boolean flag = isLoginRequest(request,response);
System.out.println("啊鹅鹅鹅饿 "+flag);
if(flag){
System.out.println("是是是是是是是");
saveRequestAndRedirectToLogin(request,response);
}
//saveRequestAndRedirectToLogin(request,response);
// return true;
//return false;
if(SecurityUtils.getSubject().isAuthenticated()) {
String successUrl = WebUtils.getSavedRequest(request).getRequestUrl();
WebUtils.redirectToSavedRequest(request, response, successUrl);
return true;//已经登录过
}else {//保存当前地址并重定向到登录界面
saveRequestAndRedirectToLogin(request, response);
saveRequest(request);
return false;
}
}
示例3: doLogin
import org.apache.shiro.web.util.WebUtils; //导入方法依赖的package包/类
@POST
@Path("/login")
public void doLogin(
@Context HttpServletRequest request,
@Context HttpServletResponse response,
@FormParam("username") String username,
@FormParam("password") String password)
throws IOException
{
Subject currentUser = SecurityUtils.getSubject();
if (!currentUser.isAuthenticated()) {
AuthenticationToken token = new UsernamePasswordToken(username, password);
currentUser.login(token);
}
WebUtils.redirectToSavedRequest(request, response, "/app");
}
示例4: issueSuccessRedirect
import org.apache.shiro.web.util.WebUtils; //导入方法依赖的package包/类
/**
* Redirects to user to the previously attempted URL after a successful login. This implementation simply calls
* <code>{@link org.apache.shiro.web.util.WebUtils WebUtils}.{@link WebUtils#redirectToSavedRequest(javax.servlet.ServletRequest, javax.servlet.ServletResponse, String) redirectToSavedRequest}</code>
* using the {@link #getSuccessUrl() successUrl} as the {@code fallbackUrl} argument to that call.
*
* @param request the incoming request
* @param response the outgoing response
* @throws Exception if there is a problem redirecting.
*/
protected void issueSuccessRedirect(ServletRequest request, ServletResponse response) throws Exception {
WebUtils.redirectToSavedRequest(request, response, getSuccessUrl());
}