Spring 如何发送get方法';是否在不使用视图的情况下将数据发送到post方法?
假设,我在get方法中有一个值/数据(在我的示例中为name),我想在post方法中发送和访问它,而不使用view。我该怎么做Spring 如何发送get方法';是否在不使用视图的情况下将数据发送到post方法?,spring,spring-mvc,model-view-controller,Spring,Spring Mvc,Model View Controller,假设,我在get方法中有一个值/数据(在我的示例中为name),我想在post方法中发送和访问它,而不使用view。我该怎么做 @RequestMapping(value="/edit",method = RequestMethod.GET) public String getPerson(ModelMap model,Person person){ String name="Person Name"; return "personEdit"; } @RequestM
@RequestMapping(value="/edit",method = RequestMethod.GET)
public String getPerson(ModelMap model,Person person){
String name="Person Name";
return "personEdit";
}
@RequestMapping(value="/save",method = RequestMethod.POST)
public String savePerson(ModelMap model,Person person){
//I want to access/get **name** here
return "details";
}
您可以使用modelMap发送值
@RequestMapping(value="/edit",method = RequestMethod.GET)
public String getPerson(ModelMap model,Person person){
String name="Person Name";
model.addAttribute("name","Person Name");
return "personEdit";
}
您可以使用JSTL forexmp:${name}访问您的值。它会将数据传递给view…但我需要在不使用view的情况下将数据从get方法发送到post方法