2016-07-29 8 views
0

として利用できる 'zipbean' Bean名用プレーンなターゲットオブジェクト誰かがこのエラーについて私を助けることができるBindingResultも要求属性

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

を表示するには、いくつかのテキストボックスに、顧客のページを持つ私はあなたがそれ春豆

の一部にするために

<form:input type="text" id="zip" path="zip" 

<input type="text" id="zip" name="zip" 

を交換する必要があることを推測します

nameの属性は、tの一部としてpathになっています彼は、

また、春のタグにadapation ZipBeanクラスが持っていることを確認してくださいprivate String zip; +

最後にgetZip()setZip(String zip)方法、POSTリクエストを処理するマッチングコントローラが持っていることを確認して、正しい@ModelAttributeが、あなたのJSPが最初にロードされない理由を尋ねると思います。

+0

同じjspにselect属性があればどうなりますか?私はフォームを追加する必要があります:選択? –

+0

yup - Springのドキュメントを見ていますが、構文は古典的なタグと99%類似しています:)ほとんどの名前=パスは属性です – niilzon

関連する問題