Javascript 中的 Struts 标签 [英] Struts tags in Javascript

查看:30
本文介绍了Javascript 中的 Struts 标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您认为更好的做法是什么?

What would you consider a better practice?

你会吗(在 JavaScript 中):

Would you do (in javascript):

var aaa = <s:property value="myValue"/>;

或者更确切地说(在一个jsp文件中):

or rather (in a jsp file):

<s:hidden  name="myValue" id="myValue" />

与(在javascript中):

with (in javascript):

var bbb = document.getElementById("myValue").value;

推荐答案

两种方式都可以达到预期的效果.唯一重要的是个人品味和偏好.

You can achieve the desired results with both way.only thing matters is individual taste and preferences.

我不想混淆这些东西,我会选择使用隐藏字段的第二种方式.对我来说,它有两个目的.

i would not like to mix up the things and will go with the second way using a hidden field.for me it serve 2 purposes.

  1. 将我的 struts2 标记与 JavaScript 分开.
  2. 此外,我可以使用标准的 JavaScript 方法编写简单干净的 JavaScript 代码,而不是将这些东西混在一起

这篇关于Javascript 中的 Struts 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆