如何在页面中获取到ModelAndView绑定的值
发布网友
发布时间:2022-05-05 17:55
我来回答
共1个回答
热心网友
时间:2022-04-22 21:26
如何在页面中获取到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);
}