将数组对象传递到struts2中的操作类

passing array object to action class in struts2

本文关键字:操作 struts2 数组 对象      更新时间:2023-09-26

我有一个jsp页面。在jsp页面中,我有一组对象,比如历史。在jquery中,我得到了索引。现在我想把history[index]对象传递给struts2中的action类。这是我尝试过的代码,但显示错误。

 $(document).ready(function() {
 $(function() {
     var rateDialog = $("#rateDialog").dialog({
         autoOpen: false,
         minHeight:250,
            width: 400,
            height: 265,  
         open: function( event, ui ) {
             $("#showDialogMessage").hide();
             $('#reviewArea').val('');
             }
         });
         $(".rate").on("click", function() {
             // Display the dialog
             rateDialog.dialog("open");
             alert( $(this).attr("id") );
             var index = $(this).attr("id");
             alert("${history.get(index)}");
         });
 });
 $("#submit").click(function(e) {
 $("#showDialogMessage").hide();
  var xmlhttp;
     $("#submit").prop('disabled',true);
     alert("called");
        var url="rate?object="+${history.get(index)};
        if (window.XMLHttpRequest)
        {
            xmlhttp=new XMLHttpRequest();
        }
        else
        {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange=function()
        {
            if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
                $("#submit").removeAttr('disabled');
                document.getElementById("showPasswordMessage").innerHTML=xmlhttp.responseText;
                $("#showPasswordMessage").show();
            }
        }
        xmlhttp.open("GET", url, true);
        xmlhttp.send();
 });
});
 var url="rate?object="+${history.get(index)};

这不是一个java问题,这是javascript。上面这条线是的罪魁祸首

${history.get(index)}

是在服务器上执行的jsp代码,它获取一个对象。打印的是对象的toString()表示形式(com.markEffy.aggregator.TransactionDetails@6e0bbea6)。您可能应该访问对象上的属性

${history.get(index).someProperty}