mammam mammam - 2 months ago 8
jQuery Question

for redirecting the different page on button submit with array to spring Controller()

on click on button(submitButton)

create a hidden from and I have sent the data,
suppose my data is [60,56]

assetGroupId: [60,56]

$("#submitButton").click(function() {
console.log("submit button is calling");

var assetID= JSON.stringify(assetGroupId);
document.body.innerHTML += '<form id="assetIdForm" action="http://localhost:9007/abcd" method="post">
<input type="hidden" name="assetID" value="assetID"></form>';
document.getElementById("assetIdForm").submit();


my controller is:

@RequestMapping(value = "/abcd", method ={ RequestMethod.POST, RequestMethod.GET },produces=MediaType.APPLICATION_JSON_VALUE,
consumes=MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ModelAndView getvalue(String[] ID) {
}


In my controller i need to get the data is [50,60], but i am getting I,D.
kindly help me.. how i can get data in controller.

Answer

try this

document.body.innerHTML += '<form id="assetIdForm" action="http://localhost:9007/abcd" method="post">
        <input type="hidden" name="assetID" value="'+assetID+'"></form>';

document.getElementById("assetIdForm").submit();

assetID as a variable inside value tag

Comments