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

标签 java struts

我在 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/

相关文章:

java - Struts1.2 Action 类没有被调用

java - Spring MVC 中的 Struts ActionMessages 相当于什么?

jsp - html表单字段作为struts表单中的数组元素

java - 显示标签库和选定的复选框值

javascript - 需要有关 HTTPSession 超时的帮助

Java - 如何结束 while 函数的进程

java - 如何传递html :text value with html:link in struts 1. 2

java - 通过socket将asn1数据从客户端发送到服务器

java - 如何使用改造获取其中的数据

java - 如何让 JLabel 和 JTextArea 对齐到屏幕的左上角而不是中心