how to set value in arraylist without loading whole page..? [closed]

岁酱吖の 提交于 2019-12-12 05:12:57

问题


I am developing web application using struts2 hibernate. How to set a value in arraylist without loading the other. Front end is JSP Page. That page has multiple arraylist. Thank you in advance..


回答1:


Hi Jegatheesh,

Your requirement is very much similar to what I have implemented few days back in my project, where I have to pass an arraylist from JSP page to my struts Action class. So I used JSON for that.

Here is the working sample of my project:-

First make an object in javascript itself

var objectDetails = {};

Now add details to this object like :-

objectDetails.ID = $("#ID").val();
objectDetails.Name = $("#Name").val();
objectDetails.Address = $("#Address").val();
objectDetails.Contact = $("#Contact").val();
objectDetails.MailID = $("#MailID").val();

then make an array and Add this object to the array

var listArray = [];
listArray.push(objectDetails);

Now your JSON object is ready with all the data. All you have to do is just send it to your STRUTS Action class via JSON as follows :-

$.getJSON('AddList', {
    JSONObjectString: JSON.stringify(ObjectDetails)
});

Here in the above code AddList is your struts action which you have to map in your struts.xml and JSONObjectString is the property name which you have to make in your action class with getters and setters. Now just club all this code and paste into a jquery button click function.. so that you can execute it.



来源:https://stackoverflow.com/questions/34413260/how-to-set-value-in-arraylist-without-loading-whole-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!