5
I have written code as given below-
@Controller
@RequestMapping("something")
public class somethingController {
@RequestMapping(value="/someUrl",method=RequestMethod.POST)
public String myFunc(HttpServletRequest request,HttpServletResponse response,Map model){
//do sume stuffs
return "redirect:/anotherUrl"; //gets redirected to the url '/anotherUrl'
}
@RequestMapping(value="/anotherUrl",method=RequestMethod.POST)
public String myAnotherFunc(HttpServletRequest request,HttpServletResponse response){
//do sume stuffs
return "someView";
}
}
我想重定向到請求方法爲POST的「anotherUrl」請求映射。如何在Spring MVC中重定向到POST
bindingResults正在以這種方式丟失先生。任何解決方案。? – masT
沒有綁定結果會丟失。這裏我們只是告訴handle方法接受GET和POST方法。 –
從技術的角度來看,這將起作用,如果您正在編寫一個RESTful應用程序,這將違反GET的「無副作用」期望 - 所以任何追求此解決方案的人都應該意識到這一慣例的突破。我建議要麼找到另一種方式,要麼記錄它真的很好(非常少) – romeara