如何将数据传递到 中?通过属性在 Struts 标记文件中标记?
我有一个包含两半的表单,一个用于将宽缩略图附加到资产,另一个用于标准尺寸的缩略图。生成页面的jsp 文件调用thumbnail.tag,它调用thumb.tag 两次:
<thumbnail:thumb label="75px Thumbnail" />
<thumbnail:thumb label="Wide Thumbnail" />
thumb.tag 依次具有以下内容:
<s:if test="#attr.label == '75px Thumbnail'">
<thumbnail:standardThumb />
</s:if>
<s:elseif test="#attr.label == 'Wide Thumbnail'">
<thumbnail:wideThumb />
</s:elseif>
standardThumb.tag 和wideThumb.tag 之间的唯一区别是变量名称,例如stdThumbUrl 和wideThumbUrl。我被分配将其重构为单个文件并传入“std”或“wide”字符串。我发现这对于常规 HTML 标签来说效果很好。例如,添加到thumb.tag:
<thumbnail:standardThumb tst="standard" />
和standardThumb.tag:
<%@ attribute name="tst" required="true"%>
...
<iframe id="${tst}ThumbImage" ... >
并且这按预期工作。我似乎无法找到一种方法将“标准”放入
<s:if test="content.standardThumbUrl != null">
同一文件中。我已经尝试了我能想到的 % 和 $ 以及 # 和 {} 的所有组合,但没有任何效果。是否有一些正确的语法可以帮助我实现我正在寻找的效果?
I have a form with two halves, one for attaching a wide thumbnail to an asset and one for a standard-size thumbnail. The jsp file generating the page calls thumbnail.tag, which calls thumb.tag twice:
<thumbnail:thumb label="75px Thumbnail" />
<thumbnail:thumb label="Wide Thumbnail" />
thumb.tag in turn has the following:
<s:if test="#attr.label == '75px Thumbnail'">
<thumbnail:standardThumb />
</s:if>
<s:elseif test="#attr.label == 'Wide Thumbnail'">
<thumbnail:wideThumb />
</s:elseif>
The sole difference between standardThumb.tag and wideThumb.tag is the variable names, e.g. stdThumbUrl and wideThumbUrl. I have been assigned to refactor this into a single file and pass in the "std" or "wide" string. I have found this works just fine with regular HTML tags. For example, added to thumb.tag:
<thumbnail:standardThumb tst="standard" />
and to standardThumb.tag:
<%@ attribute name="tst" required="true"%>
...
<iframe id="${tst}ThumbImage" ... >
and this works as expected. I can't seem to find a way to get "standard" into
<s:if test="content.standardThumbUrl != null">
in the same file. I've tried every combination of % and $ and # and {} that I can think of, but nothing has worked. Is there some proper syntax that will help me achieve the effect I'm looking for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论