Springmvc06-redirect
package com.caorui.handlers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("/springmvc")
public class MyController {
@RequestMapping("/hello")
public ModelAndView hello(String username, int age) {
ModelAndView modelAndView = new ModelAndView();
modelAndView.addObject("username", username);
modelAndView.addObject("age", age);
modelAndView.setViewName("redirect:some");
return modelAndView;
}
@RequestMapping("/some")
public ModelAndView some() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("welcome");
return modelAndView;
}
}