Controller的返回值

2021-08-21 11:30:15 字數 367 閱讀 5104

1. modelview 能進行頁面跳轉,也能進行資料封裝

2. void response 進行

json

字串的互動

3. string 才是官方文件推薦的

可以直接進行頁面的跳轉。 return "/index.jsp";

還可以進行**到其他的controller return "forward:/index.jsp";

重定向到其他的controller return "redirect:/index.jsp";

也可以進行資料的互動,互動的方式需要乙個model

然後呼叫model的

addattribute

方法

Controller的返回值

public string edititems model model throws exception 1 返回string型別 表示返回邏輯檢視名 真正檢視名 jsp路徑 字首 邏輯檢視名 字尾 2 redirect 重定向 return redirect selectitemslist.act...

Controller方法返回值

controller方法中定義modelandview物件並返回,物件中可新增model資料 指定view。入門程式 第一 包類 類包 方法名 public modelandview itemlist 參考 在controller方法形參上可以定義request和response,使用request...

controller方法返回值和引數繫結

controller方法的返回值型別 getitems public modelandview getitems throws exception querybyid public string selectbyiditems integer id,model model throws except...