Skip to content

Commit ca70e9f

Browse files
khatwaniNikhilpedja4
authored andcommitted
Changes for BAEL-332 (eugenp#2396)
1 parent 1a001a5 commit ca70e9f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎spring-rest/src/main/java/org/baeldung/web/controller/redirect/RedirectController.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package org.baeldung.web.controller.redirect;
22

3+
import javax.servlet.http.HttpServletRequest;
4+
5+
import org.springframework.http.HttpStatus;
36
import org.springframework.stereotype.Controller;
47
import org.springframework.ui.ModelMap;
58
import org.springframework.web.bind.annotation.ModelAttribute;
69
import org.springframework.web.bind.annotation.RequestMapping;
710
import org.springframework.web.bind.annotation.RequestMethod;
811
import org.springframework.web.servlet.ModelAndView;
12+
import org.springframework.web.servlet.View;
913
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
1014
import org.springframework.web.servlet.view.RedirectView;
1115

@@ -49,4 +53,16 @@ public ModelAndView redirection(final ModelMap model, @ModelAttribute("flashAttr
4953
model.addAttribute("redirectionAttribute", flashAttribute);
5054
return new ModelAndView("redirection", model);
5155
}
56+
57+
@RequestMapping(value = "/redirectPostToPost", method = RequestMethod.POST)
58+
public ModelAndView redirectPostToPost(HttpServletRequest request) {
59+
request.setAttribute(View.RESPONSE_STATUS_ATTRIBUTE, HttpStatus.TEMPORARY_REDIRECT);
60+
return new ModelAndView("redirect:/redirectedPostToPost");
61+
}
62+
63+
@RequestMapping(value = "/redirectedPostToPost", method = RequestMethod.POST)
64+
public ModelAndView redirectedPostToPost() {
65+
return new ModelAndView("redirection");
66+
}
67+
5268
}

0 commit comments

Comments
 (0)