[英]List when sent to Controller from GSP is a String?
I have a List of Strings built using Javascript on the client side which looks like this in the Javascript console: 我在客户端使用JavaScript构建的字符串列表在Javascript控制台中看起来像这样:
["No address provided.", "No telephone number provided."]
I send this to my Controller as one of the params from my GSP in an ajax call but the controller sees it like this: 我将它作为GSP的参数之一以ajax调用的形式发送到我的Controller,但Controller如下所示:
No address provided.,No telephone number provided.
ie as a String (without square brackets). 即作为字符串(不带方括号)。 This is how I am sending my params:
这就是我发送参数的方式:
<button id="save" onclick = "${remoteFunction(controller: 'customer',
action: 'saveModifiedIndividualRecord',
params: '\'uniqueId=\' + uniqueId + \'&secondaryId=\' + secondaryId + \'&redIssuesRemoved=\' + removedRedIssues + \'&yellowIssuesRemoved=\' + removedYellowIssues')}"> Save </button>
Any way so that the Controller will see it as a List and not a String? 以任何方式使控制器将其视为列表而不是字符串?
Am guessing both red or yellow issues are you list of string params. 我猜这两个红色或黄色的问题是您的字符串参数列表。 So Try def listOfRedIssue = params.list('redIssuesRemoved') .. this makes it as List or yellowIssues
所以尝试def listOfRedIssue = params.list('redIssuesRemoved')..这使其成为List或yellowIssues
Try this in your controller: 在您的控制器中尝试以下操作:
def redIssuesRemoved = params.redIssuesRemoved.tokenize(",")
def yellowIssuesRemoved = params.yellowIssuesRemoved.tokenize(",")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.