我正在使用 JSTL forEach
循环并构建表。我遇到的困难是我需要在向用户显示之前使用 Javascript 函数处理该数据。有没有一种方法/语法可以在 JSTL 渲染标签之后但再次循环之前调用 Javascript 函数?如果没有,是否有一种方法可以使用 JSTL 或 Struts 迭代来唯一且连续地标记 <td/>
带有 row:col
的元素ID,以便我稍后可以处理它们?
最佳答案
Is there a way/syntax to call a Javascript function(s) after JSTl has rendered the tag, but before it loops again?
显然不是:JSTL 处理发生在服务器端。 JS 在 JSP 完全渲染并交付给客户端之后发生。
If not, is there a way with JSTL or Struts iteration to uniquely and serially tag the elements with a row:col ID, so I can later process them?
当然,您可以将任何您想要的内容放入 DOM id
和/或 class
属性中,或者使用诸如 data-id
/之类的东西ETC。属性(如果您想将该信息分开)。
不过,最好的方法取决于您具体在做什么。
关于javascript - JSTL 和 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17241695/