我正在尝试做一个JSP页面来创建一个对象。
这是我的jsp页面:
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Kitsune</title>
</head>
<body>
<div id="wrapper">
<form:form method="POST" action="/Kitsune/formatador/handleNewCv">
<div class="row">
<div class="col-xs-4 text-right">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
<input class="btn btn-default" name="save" type="submit" value="Save" />
<input class="btn btn-default" name="submitCV" type="submit" value="Submit & Preview" />
</div>
</div>
<div class="row " id="accordion">
<div class="top-info col-xs-12">
<h4>
<a data-toggle="collapse" data-parent="#collapseOne" href="#collapseOne">Address & Contact<i class="indicator fa fa-chevron-up pull-right"></i>
</a>
<div class="clearfix info-cv">
<div class="col-xs-12">
<form role="form">
<div class="form-group">
<form:label path="address">Address</form:label>
<form:input type="text" class="form-control" path="address" />
</div>
</form>
</div>
<div class="col-xs-4">
<form role="form">
<div class="form-group">
<form:label path="postalCode">Postal Code</form:label>
<form:input type="text" class="form-control" path="postalCode" />
</div>
</form>
</div>
</div>
</body>
</html>
我的控制器
@RequestMapping(value = "/handleNewCv", method = RequestMethod.POST, params = {"save", "!submitCV"})
public String saveCV(CurriculumVitae cv, ModelMap model) {
logger.info("saving CV");
model.addAttribute("noteworthy", cv.getNoteworthy());
model.addAttribute("adress", cv.getAddress());
return "formatador/dummyf";
}
当我提交此表单时,控制器中的简历中的所有内容都为null,但如果我删除了所有<form role="form">
,那么CV对象就会有一些数据。为什么会这样?