我试图在方法内调用方法。这两种方法都存在于同一个 Controller 中。
这是我的第一个方法
@RequestMapping(value="/getDonationDetails" , method={RequestMethod.GET,RequestMethod.POST})
public String getDonationDetails() throws IOException {
return "redirect:/getPaymentDetails? msg=msg";
}
这是 getPaymentDetails 方法
@RequestMapping(value="/getPaymentDetails", method={RequestMethod.GET, RequestMethod.POST})
public String getPaymentDetails(@PathVariable String msg){
System.out.println("message is" + msg);
return "success";
}
这两种方法都存在于同一 Controller 内。但我无法调用 getPaymentDetails 方法。谁能告诉如何从 getDonationDetails 方法调用 getPaymentDetails 方法吗?
最佳答案
您不需要重定向。您只需调用该方法即可:
@RequestMapping(value="/getDonationDetails" , method={RequestMethod.GET,RequestMethod.POST})
public String getDonationDetails() throws IOException {
return getPaymentDetails("msg");
}
关于spring-mvc - 在spring mvc中调用同一 Controller 的另一个方法内的同一 Controller 的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48559608/