2013-03-02 102 views
0

想,我已經隱藏字段映射與命令豆次年春天形式如何將默認值傳遞給Spring輸入/隱藏元素?

<form:form id="mainForm" name="mainForm" 
      method="post" action="Temp.htm" commandName="tempBean"> 

    <form:hidden path="stringValue" /> 

</form:form> 

- TempBean。如果我需要傳遞一個動態的默認值給這個隱藏字段並依賴於其他一些操作?


HTML背景:

<c:set var="someVariable" value="${someValue}"/> 

<input type="hidden" 
     id="stringValue" 
     name="stringValue" 
     value="${someVariable}"/> 

<form:input><form:hidden>的標籤沒有value屬性。那麼,在這種情況下如何將默認值傳遞給命令對象呢?

我使用Spring 3.2.0。

回答

0

您可以設置默認值,您使用的是通用名稱豆

@RequestMapping(value="/someView.html", method=RequestMethod.GET) 
    public String someView(ModelMap modelMap){ 

     TempBean tempBean = new TempBean(); 
       tempBean.setStringValue(somevalue); 
     modelMap.addAttribute(tempBean); 
     return "something"; 
    } 
相關問題