class Workshop {
constructor(name, desc) {
this.name = name;
this.desc = desc;
}
getWork() {
console.log(this.name + " " + this.desc);
}
}
class Session extends Workshop {
constructor(name, desc, time){
super(name, desc);
this.time = time;
}
getSession() {
console.log(this.name + " " + this.desc + " " + this.time);
}
changeTime(newTime) {
let delta = this.time - newTime;
this.time = newTime;
}
}
let sessionList = [
sess1 = new Session('hummus', 'yamyam', 45),
sess2 = new Session('Kabab', 'mmmmmm', 70)
]
sessionList.forEach((session) => {
console.log(session.time);
});
我正在尝试将用户转发/重定向到新的JSP文件,我可以转到 @RequestMapping(value = { "postCustomer" }, consumes = "application/json", method = {RequestMethod.POST})
public ModelAndView postHome(@RequestBody JSONObject body, Model model) throws JSONException {
ModelAndView mav = new ModelAndView("redirect:/feasibility");
return mav;
}
@GetMapping(value = { "feasibility" }) // GET MAPPING
public String feasibility(ModelAndView model) throws Exception {
return "feas";
}
并进行更新,但是当我发布<url>/feasibility
时,它不会重定向或更新视图。我也尝试过使用JSP“ feas”创建一个postCustomer
,然后在ModelAndView
中返回它,但这也不起作用。我不确定是否遗漏了明显的内容,还是必须执行其他步骤来更新视图。
如果任何人有任何建议或解决方案,我将不胜感激。
答案 0 :(得分:0)
重定向将被视为新请求,尝试转发该请求
重定向和转发不是同一件事
@RequestMapping(value = { "postCustomer" }, consumes = "application/json", method = {RequestMethod.POST})
public ModelAndView postHome(@RequestBody JSONObject body, Model model) throws JSONException {
ModelAndView mav = new ModelAndView("forward:/feasibility");
//data to forward
mav.addAttribute("data", data);
return mav;
}