Spring Framework RedirectView - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework RedirectView class.

This code example shows how to use the following methods:setContextRelative
 
	public RedirectViewControllerRegistration(String urlPath, String redirectUrl) {
		Assert.notNull(urlPath, "'urlPath' is required.");
		Assert.notNull(redirectUrl, "'redirectUrl' is required.");
		this.urlPath = urlPath;
		this.redirectView = new RedirectView(redirectUrl);
		this.redirectView.setContextRelative(true);
		this.controller.setView(this.redirectView);
	} 
 
 
	/** 
	 * Set the specific redirect 3xx status code to use. 
	 * 
	 * <p>If not set, {@link org.springframework.web.servlet.view.RedirectView} 
	 * will select {@code HttpStatus.MOVED_TEMPORARILY (302)} by default. 
	 */ 
	public RedirectViewControllerRegistration setStatusCode(HttpStatus statusCode) {
		Assert.isTrue(statusCode.is3xxRedirection(), "Not a redirect status code.");
		this.redirectView.setStatusCode(statusCode);
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getUrl, render, setUrl
        super(url, true); 
    } 
 
    @Override 
    public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception { 
        setUrl(request.getServletPath() + getUrl()); 
        super.render(model, request, response); 
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addStaticAttribute
    	Recipe r = (Recipe) command;
    	recipeManager.saveRecipe(r);
     
    	System.out.println("Saving recipe: " + r.getTitle());
    	 
		RedirectView view = new RedirectView(getSuccessView());
		view.addStaticAttribute(RECIPE_ID_ATTRIBUTE, Long.valueOf(recipeManager.getId(r)));
		 
		System.out.println("Save recipe successfully. id=" + Long.valueOf(recipeManager.getId(r)));
		System.out.println(recipeManager.getAllRecipes().size() + " recipes saved.");
		 
		return new ModelAndView(view);
    } 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setExposeModelAttributes
 
	private String pageType; 
	 
	private boolean addRequestParameters; 
 
	public PageView(String pageType) { 
		this.pageType = pageType; 
		setExposeModelAttributes(false); 
	} 
 
	public PageView addRequestParameters() { 
		addRequestParameters = true; 
		return this; 
	} 
	 
	@Override 
	public void render(Map<String, ?> model, HttpServletRequest request,  
			HttpServletResponse response) throws Exception { 
 
		Site site = PageResolver.getSite(request); 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
		assertEquals("attrValue", mavContainer.getModel().get("attrName")); 
	} 
 
	@Test 
	public void handleViewInstance() throws Exception { 
		ModelAndView mav = new ModelAndView(new RedirectView(), "attrName", "attrValue"); 
		handler.handleReturnValue(mav, returnParamModelAndView, mavContainer, webRequest); 
 
		assertEquals(RedirectView.class, mavContainer.getView().getClass()); 
		assertEquals("attrValue", mavContainer.getModel().get("attrName")); 
	} 
 
	@Test 
	public void handleNull() throws Exception { 
		handler.handleReturnValue(null, returnParamModelAndView, mavContainer, webRequest); 
 
		assertTrue(mavContainer.isRequestHandled()); 
	} 
 
	@Test 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:doCreateTargetUrl, sendRedirect
	} 
 
	@Override 
	protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, 
			HttpServletResponse response) throws IOException { 
		String targetUrl = doCreateTargetUrl(model, request); 
		sendRedirect(request, response, targetUrl, this.http10Compatible); 
	} 
 
	public void render(Map<String, ?> model, FacesContext facesContext) throws Exception { 
		HttpServletRequest request = (HttpServletRequest) facesContext.getExternalContext().getRequest(); 
		String targetUrl = doCreateTargetUrl(model, request); 
		facesContext.getExternalContext().redirect(targetUrl); 
	} 
 
	public String getBookmarkUrl(Map<String, ?> model, HttpServletRequest request) throws IOException { 
		return doCreateTargetUrl(model, request); 
	} 
 
	private String doCreateTargetUrl(Map<String, ?> model, HttpServletRequest request) 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	 *      javax.servlet.http.HttpServletResponse, java.lang.Object, 
	 *      org.springframework.validation.BindException) 
	 */ 
	protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, 
	        BindException errors) throws Exception { 
		return new ModelAndView(new RedirectView(getSuccessView())); 
	} 
	 
	/** 
	 * This is called prior to displaying a form for the first time. It tells Spring the 
	 * form/command object to load into the request 
	 *  
	 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) 
	 */ 
	protected List<String> formBackingObject(HttpServletRequest request) throws ServletException { 
		Appender appender = Logger.getRootLogger().getAppender("MEMORY_APPENDER"); 
		if (appender instanceof MemoryAppender) { 
			MemoryAppender memoryAppender = (MemoryAppender) appender; 
			return memoryAppender.getLogLines(); 
			 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
 
	public ModelAndView handleRequest(HttpServletRequest request,  
			HttpServletResponse response) throws Exception { 
 
		LoginManager.logout(request, response); 
		return new ModelAndView(new RedirectView(servletPrefix + goodbyUrl, true)); 
	} 
 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        if (credentials != null) { 
            // get user profile 
            final CasProxyProfile casProxyProfile = (CasProxyProfile) client.getUserProfile(credentials, context); 
            // get proxy ticket 
            final String proxyTicket = casProxyProfile.getProxyTicketFor(SERVICE_URL); 
            return new ModelAndView(new RedirectView(CommonHelper.addParameter(SERVICE_URL, "ticket", proxyTicket))); 
        } else { 
            // mode proxy 
        } 
        return null; 
    } 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        } catch (MailException me) { 
            log.warn(me.getMessage()); 
            saveError(request, me.getCause().getLocalizedMessage()); 
        } 
 
        return new ModelAndView(new RedirectView(request.getContextPath())); 
    } 
 
    @SuppressWarnings("unchecked") 
    public void saveError(HttpServletRequest request, String error) { 
        List errors = (List) request.getSession().getAttribute("errors"); 
        if (errors == null) { 
            errors = new ArrayList(); 
        } 
        errors.add(error); 
        request.getSession().setAttribute("errors", errors); 
    } 
 
    // this method is also in BaseForm Controller 
    @SuppressWarnings("unchecked") 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Spring Framework RedirectView Methods: