2014-07-07 74 views

回答

0

您可以使用JavaScript代碼進行AJAX調用,並把這些值在該領域的下列結果頁面需要的數據

<script type="text/javascript"> 
     function ajaxLink(url, params, displayComponentId) { 
        $.post(url, params, function(data) { 
         document.getElementById('fieldId').value =data.name; 
        }); 
       } 
     function onClickMethod(val){ 
      ajaxLink('/myProject/getTags', {'tagName': val}, 'viewDiv'); 
     } 
</script> 

fieldId應該是相應字段的ID。

裏面,你必須遵循下面的代碼在Spring MVC中

@RequestMapping(value = "/getTags", method = RequestMethod.POST) 
@ResponseBody public User getTags(@RequestParam("tagName") String 
tagName) 
{ 
     User user=new User(); 
     //Write a method to access the data from DB 
     user.setName("test") 
     return user; 
} 

嘗試它的服務器端。它適用於我與春天MVC + Bootstrap

+0

謝謝!!!它幫助我做Spring MVC。我需要的確切代碼。 –

1

你可以嘗試調用模式像這裏面的自定義網址:

function load_modal(ev){ 
    if (ev && ev.preventDefault) 
     ev.preventDefault(); // prevent navigation 
    var url = "" //construct your url with all parameters that you need 
    //avoid cache 
    url +="&_="+(new Date()).getTime() 
    $("#modal").load(url, function() { // load the url into the modal 
      $(this).modal('show'); // display the modal on url load 
    }); 
    return false; // prevent the click propagation 
} 

該URL會調用服務器端的動作和填入您在將顯示在模態

+0

謝謝你的建議。 –

相關問題