如何在页面中获取到ModelAndView绑定的值
1个回答
2017-01-16
展开全部
如何在页面中获取到ModelAndView绑定的值
@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView myMethod(HttpServletRequest request,
HttpServletResponse response,
//@RequestParam("username")String username, @RequestParam("password")String password
String username,String password,//如果和前台的一样一样简写成这样
ModelMap modelMap) throws Exception {
username = new String(username.getBytes("iso8859-1"),"UTF-8");//编码问题 (服务器一帮都是iso的)
System.out.println(username+":"+password);
modelMap.put("loginUser", username);
modelMap.put("msg", "I'm in session");
return new ModelAndView("/view/hello", modelMap);
}
@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView myMethod(HttpServletRequest request,
HttpServletResponse response,
//@RequestParam("username")String username, @RequestParam("password")String password
String username,String password,//如果和前台的一样一样简写成这样
ModelMap modelMap) throws Exception {
username = new String(username.getBytes("iso8859-1"),"UTF-8");//编码问题 (服务器一帮都是iso的)
System.out.println(username+":"+password);
modelMap.put("loginUser", username);
modelMap.put("msg", "I'm in session");
return new ModelAndView("/view/hello", modelMap);
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询