用于重定向按钮提交的不同页面与数组到弹簧控制器()(for redirecting the different page on button submit with array to spring Controller())
点击按钮(submitButton)
创建一个隐藏的,我发送了数据,假设我的数据是[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();我的控制器是:
@RequestMapping(value = "/abcd", method ={ RequestMethod.POST, RequestMethod.GET },produces=MediaType.APPLICATION_JSON_VALUE, consumes=MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ModelAndView getvalue(String[] ID) { }在我的控制器中,我需要得到的数据是[50,60],但我得到了我,D。 请帮助我..如何在控制器中获取数据。
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.
最满意答案
尝试这个
document.body.innerHTML += '<form id="assetIdForm" action="http://localhost:9007/abcd" method="post"> <input type="hidden" name="assetID" value="'+assetID+'"></form>';的document.getElementById( “assetIdForm”)提交()。
assetID作为变量内部值标记
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
更多推荐
发布评论