org.springframework.web.servlet.ModelAndViewDefiningException Java Examples

The following examples show how to use org.springframework.web.servlet.ModelAndViewDefiningException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuthenticInterceptor.java    From oslits with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 세션에 계정정보(LoginVO)가 있는지 여부로 인증 여부를 체크한다.
 * 계정정보(LoginVO)가 없다면, 로그인 페이지로 이동한다.
 */
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

	boolean isPermittedURL = false;

	LoginVO loginVO = (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();

	if(loginVO != null){
		return true;
	} else if(!isPermittedURL){
			ModelAndView modelAndView = new ModelAndView("redirect:/uat/uia/egovLoginUsr.do");
			throw new ModelAndViewDefiningException(modelAndView);
		}else{
			return true;
		}
}
 
Example #2
Source File: SignonInterceptor.java    From jpetstore-kubernetes with Apache License 2.0 6 votes vote down vote up
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
		throws Exception {
	UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
	if (userSession == null) {
		String url = request.getServletPath();
		String query = request.getQueryString();
		ModelAndView modelAndView = new ModelAndView("SignonForm");
		if (query != null) {
			modelAndView.addObject("signonForwardAction", url+"?"+query);
		}
		else {
			modelAndView.addObject("signonForwardAction", url);
		}
		throw new ModelAndViewDefiningException(modelAndView);
	}
	else {
		return true;
	}
}
 
Example #3
Source File: OrderFormController.java    From jpetstore-kubernetes with Apache License 2.0 6 votes vote down vote up
protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException {
	UserSession userSession = (UserSession) request.getSession().getAttribute("userSession");
	Cart cart = (Cart) request.getSession().getAttribute("sessionCart");
	if (cart != null) {
		// Re-read account from DB at team's request.
		Account account = this.petStore.getAccount(userSession.getAccount().getUsername());
		OrderForm orderForm = new OrderForm();
		orderForm.getOrder().initOrder(account, cart);
		return orderForm;
	}
	else {
		ModelAndView modelAndView = new ModelAndView("Error");
		modelAndView.addObject("message", "An order could not be created because a cart could not be found.");
		throw new ModelAndViewDefiningException(modelAndView);
	}
}
 
Example #4
Source File: SignonInterceptor.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
		throws Exception {
	UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
	if (userSession == null) {
		String url = request.getServletPath();
		String query = request.getQueryString();
		ModelAndView modelAndView = new ModelAndView("SignonForm");
		if (query != null) {
			modelAndView.addObject("signonForwardAction", url+"?"+query);
		}
		else {
			modelAndView.addObject("signonForwardAction", url);
		}
		throw new ModelAndViewDefiningException(modelAndView);
	}
	else {
		return true;
	}
}
 
Example #5
Source File: OrderFormController.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected Object formBackingObject(HttpServletRequest request) throws ModelAndViewDefiningException {
	UserSession userSession = (UserSession) request.getSession().getAttribute("userSession");
	Cart cart = (Cart) request.getSession().getAttribute("sessionCart");
	if (cart != null) {
		// Re-read account from DB at team's request.
		Account account = this.petStore.getAccount(userSession.getAccount().getUsername());
		OrderForm orderForm = new OrderForm();
		orderForm.getOrder().initOrder(account, cart);
		return orderForm;
	}
	else {
		ModelAndView modelAndView = new ModelAndView("Error");
		modelAndView.addObject("message", "An order could not be created because a cart could not be found.");
		throw new ModelAndViewDefiningException(modelAndView);
	}
}
 
Example #6
Source File: AuthInterceptor.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
private void throwAuthException(String message) throws ModelAndViewDefiningException {
    logger.warn(message);
    throw new ModelAndViewDefiningException(ControllerUtils.createJsonView(false, message));
}