Changes for BAEL-332 (#2396)
This commit is contained in:
		
							parent
							
								
									1a001a5a68
								
							
						
					
					
						commit
						ca70e9f9fb
					
				| @ -1,11 +1,15 @@ | |||||||
| package org.baeldung.web.controller.redirect; | package org.baeldung.web.controller.redirect; | ||||||
| 
 | 
 | ||||||
|  | import javax.servlet.http.HttpServletRequest; | ||||||
|  | 
 | ||||||
|  | import org.springframework.http.HttpStatus; | ||||||
| import org.springframework.stereotype.Controller; | import org.springframework.stereotype.Controller; | ||||||
| import org.springframework.ui.ModelMap; | import org.springframework.ui.ModelMap; | ||||||
| import org.springframework.web.bind.annotation.ModelAttribute; | import org.springframework.web.bind.annotation.ModelAttribute; | ||||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||||
| import org.springframework.web.bind.annotation.RequestMethod; | import org.springframework.web.bind.annotation.RequestMethod; | ||||||
| import org.springframework.web.servlet.ModelAndView; | import org.springframework.web.servlet.ModelAndView; | ||||||
|  | import org.springframework.web.servlet.View; | ||||||
| import org.springframework.web.servlet.mvc.support.RedirectAttributes; | import org.springframework.web.servlet.mvc.support.RedirectAttributes; | ||||||
| import org.springframework.web.servlet.view.RedirectView; | import org.springframework.web.servlet.view.RedirectView; | ||||||
| 
 | 
 | ||||||
| @ -49,4 +53,16 @@ public class RedirectController { | |||||||
|         model.addAttribute("redirectionAttribute", flashAttribute); |         model.addAttribute("redirectionAttribute", flashAttribute); | ||||||
|         return new ModelAndView("redirection", model); |         return new ModelAndView("redirection", model); | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     @RequestMapping(value = "/redirectPostToPost", method = RequestMethod.POST) | ||||||
|  |     public ModelAndView redirectPostToPost(HttpServletRequest request) { | ||||||
|  |         request.setAttribute(View.RESPONSE_STATUS_ATTRIBUTE, HttpStatus.TEMPORARY_REDIRECT); | ||||||
|  |         return new ModelAndView("redirect:/redirectedPostToPost"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @RequestMapping(value = "/redirectedPostToPost", method = RequestMethod.POST) | ||||||
|  |     public ModelAndView redirectedPostToPost() { | ||||||
|  |         return new ModelAndView("redirection"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user