springmvc controll与jsp数据显示
controll 層 返回jsp 頁面,同時返回數(shù)據(jù)顯示在jsp 里面
controll層有幾種寫法:
寫法一:
@RequestMapping(value = "/addUser")
public String addUser(HttpServletRequest req, ModelMap model) {
String username = req.getParameter("username");
//設(shè)置返回到j(luò)sp的數(shù)據(jù)
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頁面獲取數(shù)據(jù)方式
${result}
就可以顯示了
總結(jié)
以上是生活随笔為你收集整理的springmvc controll与jsp数据显示的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 碰撞和触发
- 下一篇: rr rom Android6,RR R