div中的Struts2标签显示为空 [英] Struts2 tags in divs appear empty

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

问题描述

我在html div中有一个s:复选框。当代码运行时,复选框在外部(两个)div和divs似乎是空的和不存在的。为什么这会发生,如何解决它?当我将随机文本放在div中时,div包含它。我将背景颜色设置为红色,以便我可以检测到div。

I have a s:checkbox inside a html div. When the code is run, the checkbox is outside (both) the div and the divs seem to be empty and nonexistant. Why is this occuring and how can I fix it? When I place random text inside either div, the div contains it. I set the background color to red so I can detect the div.

<div id="outer">
    <div id="inner">
        <s:checkbox name="chBx" id"chBx" fieldValue="false" value="true" label="Check 
            This" />
    </div>
</div>


推荐答案

这个答案(你应该考虑upvoting也),Struts2生成(或不生成)某种呈现Struts代码时的HTML,基于主题

Like described in this answer (that you should consider upvoting too), Struts2 generates (or not) a certain kind of HTML when rendering Struts Tags, basing on the Theme you have chosen.

默认值为 xhtml ,将生成很多的东西。它可能方便,但也恼人,根据你的工作方式。我个人更喜欢自己生成HTML,然后我使用的主题不会生成几乎任何HTML:简单主题。

The default one is xhtml, that will generate a lot of stuff for you. It may be handy, but also annoying, according to how you work. Personally I prefer to generate the HTML by myself, and then I use the theme that won't generate almost any HTML: the simple Theme.

请注意,在处理大型项目或具有相同特殊需求的多个项目时,您还可以编写自己的自定义主题(例如自动生成安全性令牌)。

Note that when working on big projects or with multiple projects with the same, particular needs, you can also write your own custom theme (for example for generating security tokens automatically).

您可以在全局(在struts.xml中)使用主题

You can use a theme globally (in struts.xml)

<constant name="struts.ui.theme" value="simple" />

或本地添加到单个标签/表单:

or locally to a single tag / form:

<s:checkbox name="chBx" id"chBx" fieldValue="false" 
           theme="simple"
           value="true" label="Check This" />

在这种情况下,您可能需要写< label& / code>对象。

In this case, you may need to write the <label> object by yourself.

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

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