用于重定向按钮提交的不同页面与数组到弹簧控制器()(for redirecting the different page on button submit with array to spring C

编程入门 行业动态 更新时间:2024-10-28 07:18:56
用于重定向按钮提交的不同页面与数组到弹簧控制器()(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

更多推荐

本文发布于:2023-07-31 21:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1349020.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   弹簧   控制器   重定向   按钮

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!