2015-02-11 86 views
0

我現在正在做的是在JavaScript中爲頁面添加一個表單。正常的標籤獲得appendend,但當我嘗試追加彈簧形式 標記它不會工作有沒有什麼辦法可以完成它。應用程序是單頁app.so表單是在javascript中生成並附加在html中。通過JavaScript創建一個彈簧表單,並附加在div

function createPage(){ 
var htmlcontent="<div class='box-content'>" 

       +"<form:form action='UserController/addUser' id='userAddForm' method='post' commandName='userObj'>" 

       +"<div class='form-group'>" 
       +"<label class='control-label'>First Name</label>" 
       +"<form:input path='firstname' class='form-control'/>" 
       +"</div>" 
       +"</div>" 
$("#content").html(htmlcontent); 

} 

回答

2

你不能用javascript動態創建spring窗體。 你可以在你的jsp中創建一個在服務器端編譯的spring表單,然後轉移到你的瀏覽器。

服務器端需要知道哪些表單和輸入元素被管理來處理它們。

+0

Yup意識到它,但如果可能的話,有沒有辦法實現它。 – user3829082 2015-02-12 09:02:20