springmvc controll与jsp数据显示
controll 層 返回jsp 頁面,同時返回數據顯示在jsp 里面
controll層有幾種寫法:
寫法一:
@RequestMapping(value = "/addUser")
public String addUser(HttpServletRequest req, ModelMap model) {
String username = req.getParameter("username");
//設置返回到jsp的數據
model.put("result", "add ok");
return "login";
}
寫法二:
@RequestMapping(value="/getdomain/{input}")
public String getDomain(@PathVariable("input") String input) {
?
ModelAndView modelandView = new ModelAndView();
modelandView.addObject("result", "111");
return "login";
}
寫法三:
@RequestMapping(value="/getdomain/{input}")
public ModelAndView getDomain(@PathVariable("input") String input) {
?
ModelAndView modelandView = new ModelAndView(“login”);
modelandView.addObject("result", "111");
return modelandView
}
jsp頁面獲取數據方式
${result}
就可以顯示了
總結
以上是生活随笔為你收集整理的springmvc controll与jsp数据显示的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 碰撞和触发
- 下一篇: rr rom Android6,RR R