gpt4 book ai didi

java - 如何在 JavaScript 中使用 struts taglib 标签

转载 作者:太空宇宙 更新时间:2023-11-04 07:26:13 24 4
gpt4 key购买 nike

我在 JS 函数中使用了 struts 标签,即

var ptp = "<c:out value='${myFormBean.myVar[0]}'/>";

它通过从适当的bean中获取正确的值,但我必须将它用于使用循环显示的多行,这就是为什么我在函数中发送行索引,但是当我尝试将该变量放入上面的行时,例如

function myFucn(ind){
var ptp = "<c:out value='${myFormBean.myVar[ind]}'/>";// this does not show any thing
//OR
var ptp = "<c:out value='${myFormBean.myVar['+ind+']}'/>";//This beaks the HTML
//OR
var ptp = "<c:out value='${myFormBean.myVar["+ind+"]}'/>";//This beaks the HTML
}

请帮助如何使用索引作为变量从上述标记中获取值。提前致谢。

最佳答案

JavaScript is a code running in the Client side, It will only be functional when the Code is executed, I mean Called using a function or Some.!! So i believe its not possible to get the values in the JavaScript from the struts Tag..!!

可能的方法是将值作为参数传递,您可以传递值使用

myFucn(indValue,'<c:out value='${myFormBean.myVar[ind]}'/>','<c:out value='${myFormBean.myVar['+ind+']}'/>','<c:out value='${myFormBean.myVar["+ind+"]}'/>')

通过这个,您的函数将在脚本函数中接收该值。

关于java - 如何在 JavaScript 中使用 struts taglib 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18503264/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com