提交的标签的name属性要和java中model属性这两个单词一模一样才行

@RequestMapping(value="/modelautobind", method = {RequestMethod.POST})
public String modelAutoBind(HttpServletRequest request, Model model, AccountModel accountModel){
    
    model.addAttribute("accountmodel", accountModel);
    return "modelautobindresult";
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
    <form:form modelAttribute="accountmodel" method="post">     
        用户名:<form:input path="username"/><br/>
        密 码:<form:password path="password"/><br/>
        <input type="submit" value="Submit" />
    </form:form>  
</body>
</html>

 

相关文章:

  • 2021-10-04
  • 2022-12-23
  • 2021-05-30
  • 2022-12-23
  • 2021-08-15
  • 2021-04-19
  • 2021-12-19
  • 2021-07-21
猜你喜欢
  • 2022-03-05
  • 2021-12-18
  • 2022-12-23
  • 2021-11-02
  • 2021-12-25
  • 2022-02-12
  • 2021-11-23
相关资源
相似解决方案