Java Code Examples for org.springframework.web.servlet.view.RedirectView

Following code examples demonstrate how to use org.springframework.web.servlet.view.RedirectViewfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.web.servlet.view.RedirectViewand various code implementation of this class.

	public org.springframework.web.servlet.view.RedirectView AllActS() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setUrl("/activity/allAct.v");
		redirectView.setContextRelative(true);
		return redirectView;
	} 


	public RedirectView addCart() {
		RedirectView view = new RedirectView();
		view.setUrl("/store/index.v");
		view.setContextRelative(true);
		return view;
	} 

	public RedirectView giftSendPage() {
		RedirectView view = new RedirectView();
		view.setUrl("/gift/giftSendingProceed.v");
		view.setContextRelative(true);
		return view;
	} 

	public RedirectView reply_R() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setContextRelative(true);
		redirectView.setUrl("/manager/reply.v");
		return redirectView;
	} 

	public org.springframework.web.servlet.view.RedirectView myalbumRefresh() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setUrl("/photo/myalbum.v");
		redirectView.setContextRelative(true);
		return redirectView;
	} 

	public org.springframework.web.servlet.view.RedirectView ActSecede() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setUrl("/activity/secede.v");
		redirectView.setContextRelative(true);
		return redirectView;
	} 

	public org.springframework.web.servlet.view.RedirectView friendalbumRefresh() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setUrl("/photo/friendalbum.v");
		redirectView.setContextRelative(true);
		return redirectView;
	} 

	public RedirectView dealList() {
		RedirectView view = new RedirectView();
		view.setUrl("/deal/index.v");
		view.setContextRelative(true);
		return view;
	} 

	public org.springframework.web.servlet.view.RedirectView error_page_r() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setUrl("/error/404.v");
		redirectView.setContextRelative(true);
		return redirectView;
	} 

	public org.springframework.web.servlet.view.RedirectView login_success() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setUrl("/index.jsp");
		redirectView.setContextRelative(true);
		return redirectView;
	} 

	public RedirectView adjustSuccess() {
		RedirectView view = new RedirectView();
		view.setUrl("/store/cart.v");
		view.setContextRelative(true);
		return view;
	} 

	public org.springframework.web.servlet.view.RedirectView albumRefresh() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setUrl("/photo/showalbum.v");
		redirectView.setContextRelative(true);
		return redirectView;
	} 

	public RedirectView reportdetail_R() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setContextRelative(true);
		redirectView.setUrl("/report/reportDetail.v");
		return redirectView;
	} 

	public RedirectView reportUpdate_R() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setContextRelative(true);
		redirectView.setUrl("/report/reportUpdate.v");
		return redirectView;
	} 

	public RedirectView productMaintainR() {
		RedirectView view = new RedirectView();
		view.setUrl("/store/pMaintenance.v");
		view.setContextRelative(true);
		return view;
	} 

	public org.springframework.web.servlet.view.RedirectView photoshow_R() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setUrl("/photo/showphoto.v");
		redirectView.setContextRelative(true);
		return redirectView;
	} 

	public org.springframework.web.servlet.view.RedirectView myActivityIndex() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setUrl("/photo/myActivity.v");
		redirectView.setContextRelative(true);
		return redirectView;
	} 

	public RedirectView productSingleR() {
		RedirectView view = new RedirectView();
		view.setUrl("/store/pSingle.v");
		view.setContextRelative(true);
		return view;
	} 

	public RedirectView reportReply_R() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setContextRelative(true);
		redirectView.setUrl("/manager/reportReply.v");
		return redirectView;
	} 

	public RedirectView replyfollowup_R() {
		org.springframework.web.servlet.view.RedirectView redirectView = new org.springframework.web.servlet.view.RedirectView();
		redirectView.setContextRelative(true);
		redirectView.setUrl("/manager/replyfollowup.v");
		return redirectView;
	} 

    public View dashboard(String employeeEmail, String employeePassword, HttpServletRequest request) {


        Iterable<User> users = null;
        users = userDAO.findByEmployeeEmail(employeeEmail);

        int i = 0;
        HashMap<Integer,User> usersHashMap = new HashMap<>();
        for(User user:users) {
            usersHashMap.put(i,user);
            i++;
        }

        User loggedUser = usersHashMap.get(0);
        if(loggedUser.getEmpoyeePassword().equals(employeePassword)){
            request.getSession().setAttribute("username",loggedUser.getEmployeeName());
            request.getSession().setAttribute("userId",loggedUser.getEmployeeId());

            if(loggedUser.getEmployeePosition() == User.EmployeePosition.EMPLOYEE) {
                return new RedirectView("/employee/");
            } else if (loggedUser.getEmployeePosition() == User.EmployeePosition.MANAGER) {
                return new RedirectView("/manager/");
            } else if (loggedUser.getEmployeePosition() == User.EmployeePosition.OWNER) {
                return new RedirectView("/owner/");
            }

        } else {
            return new RedirectView("/login/");
        }
        return new RedirectView("/login/");
    } 

Advertisement
Javadoc
View that redirects to an absolute, context relative, or current request relative URL. The URL may b

e a URI template in which case the URI template variables will be replaced with values available in the model. By default all primitive model attributes (or collections thereof) are exposed as HTTP query parameters (assuming they've not been used as URI template variables), but this behavior can be changed by overriding the #isEligibleProperty(String, Object) method.

A URL for this view is supposed to be a HTTP redirect URL, i.e. suitable for HttpServletResponse's sendRedirect method, which is what actually does the redirect if the HTTP 1.0 flag is on, or via sending back an HTTP 303 code - if the HTTP 1.0 compatibility flag is off.

Note that while the default value for the "contextRelative" flag is off, you will probably want to almost always set it to true. With the flag off, URLs starting with "/" are considered relative to the web server root, while with the flag on, they are considered relative to the web application root. Since most web applications will never know or care what their context path actually is, they are much better off setting this flag to true, and submitting paths which are to be considered relative to the web application root.

NOTE when using this redirect view in a Portlet environment: Make sure that your controller respects the Portlet sendRedirect constraints. @author Rod Johnson @author Juergen Hoeller @author Colin Sampaleanu @author Sam Brannen @author Arjen Poutsma @author Rossen Stoyanchev @see #setContextRelative @see #setHttp10Compatible @see #setExposeModelAttributes @see javax.servlet.http.HttpServletResponse#sendRedirect

Read More
Advertisement