有人可以帮我解决此错误
的index.jsp
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<head>
<body>
<jsp:include page="links.jsp"/>
<script src="<%=request.getContextPath()%>/js/welcome.js"></script>
<form:form action="${pageContext.request.contextPath}/Customer" method="POST" modelAttribute="zipbean">
<input type="text" id="zip" name="zip" class="form-control search ui-autocomplete" onkeypress=" return validate(event)" onkeydown="getData('${pageContext.request.contextPath}/ZipController/autoComplete');" />
<form:button path="zipone" class="btn btn-success">Get a Quote</form:button>
</center>
</form:form>
</body>
</html>
CustomerController
@Controller
@RequestMapping("/Customer")
public class CustomerController
{
@Autowired
ZipDao zipDao;
@RequestMapping(method = RequestMethod.GET)
public String init(HttpServletRequest request,HttpServletResponse responce,ModelMap model)
{
System.out.println("customer page started");
ZipBean zipbean=new ZipBean();
model.addAttribute("zipbean", zipbean);
return "customer";
}
}
我的客户页面上有一些文本框要显示
答案 0 :(得分:0)
我想你应该替换
<input type="text" id="zip" name="zip"
带
<form:input type="text" id="zip" path="zip"
使其成为Spring Bean的一部分
请注意,name
属性变为path
,作为适应spring标记的一部分
另外,请确保ZipBean
班级有private String zip;
+ getZip()
和setZip(String zip)
方法
最后,确保将处理POST请求的匹配控制器具有正确的@ModelAttribute
,但我想你问为什么你的jsp不会首先加载