我想知道如何在其余服务中将数据从一个RequestMethod.POST发送到另一个。
我想从Orgin和Departure do / connect发送数据,该数据发生在后端并显示结果,
我考虑过要使用数据库来完成此操作,但我认为这是不正确的。
我使用百里香叶从用户那里获取数据。
请帮助
@RequestMapping(value = "/Orgin", method = RequestMethod.GET)
public ModelAndView orgin() {
return new ModelAndView("Orgin.html", "FlightDTO", new FlightDTO());
}
@RequestMapping(value = "/Orginconnect", method = RequestMethod.POST)
public String orginconnect(@Valid @ModelAttribute("FlightDTO") FlightDTO flightDTO, BindingResult result, ModelMap model) {
return "Departure.html";
}
@RequestMapping(value = "/Departure", method = RequestMethod.GET)
public ModelAndView departure() {
return new ModelAndView("Departure.html", "FlightDTO", new FlightDTO());
}
@RequestMapping(value = "/DepartureConnect", method = RequestMethod.POST)
public String departureconnect(@Valid @ModelAttribute("FlightDTO") FlightDTO flightDTO, BindingResult result, ModelMap model) {
System.out.println(flightDTO.getOrigin());
return "Test.html";
}
@RequestMapping(value = "/Search", method = RequestMethod.GET)
public ModelAndView showForm() {
return new ModelAndView("Test.html", "FlightDTO", new FlightDTO());
}
@RequestMapping(value = "/connect", method = RequestMethod.POST)
public String submit(@Valid @ModelAttribute("FlightDTO") FlightDTO flightDTO, BindingResult result, ModelMap model) {
String Request = buildurl.url(flightDTO);
try {
buildurl.url(flightDTO);
} catch (Exception e) {
System.out.println("Invalid data can not build an URL" + e);
}
try {
connectServiceIml.connect(buildurl.url(flightDTO));
} catch (Exception e) {
System.out.println("Problem with connection" + e);
}
String output = connectServiceIml.connect(Request) ;
try {
model.addAttribute("AirlineFirst", searchResult.getAirlineFirst(output));
model.addAttribute("AirlineSecond", searchResult.getAirlineSecond(output));
model.addAttribute("AirlineThird", ////.... some code
return "Results.html";
}
答案 0 :(得分:-1)
如果方法在同一模块中,为什么不直接调用它。如果没有,则可以使用rest api调用。