Spring mvc框架controller获取表单值的方法有哪些
展开全部
@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);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询