java 如何为 Form 禁用 struts 2 表生成?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4561179/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable struts 2 Table generation for Form?
提问by zawhtut
Struts 2 automatically generate HTML table for it's <s:form>
tag. How can I disable it? Any help will be appreciated. Thank You.
Struts 2 自动为其<s:form>
标签生成 HTML 表格。我怎样才能禁用它?任何帮助将不胜感激。谢谢。
回答by Umesh Awasthi
Struts2 have theme generation functionality based on which it generares either Table based HTMl code for its tags default is x_html which is your case . You can avoid this by setting theme as simple on page level or each tags has theme property which will generate div based html contents
Struts2 具有主题生成功能,基于该功能,它的标签默认基于表格的 HTMl 代码是 x_html,这就是您的情况。您可以通过在页面级别将主题设置为简单或每个标签具有将生成基于 div 的 html 内容的主题属性来避免这种情况
<s:form name="test" theme="simple">
or you can set theme for entire page as below static value
或者您可以将整个页面的主题设置为以下静态值
<s:set name="theme" value="'simple'" scope="page" />
property
财产
<s:set name="theme" value="%{myTheme}" scope="page" />
you can set it across entire application by
您可以通过以下方式在整个应用程序中设置它
<constant name="struts.ui.theme" value="simple" />
回答by Muthu
Just add
只需添加
<struts>
<constant name="struts.ui.theme" value="simple" />
<package name="default" extends="struts-default">
constant name="struts.ui.theme" value="simple"in struts.xml. It wont apply struts default themes.
struts.xml 中的常量名称="struts.ui.theme" value="simple"。它不会应用 struts 默认主题。
回答by Akku
Another possibility would be using the usual HTML tag.
另一种可能性是使用通常的 HTML 标签。
回答by Jose Miguel
setting simple theme avoids the use of advanced validation in forms (i think). you should use css_xhtml template either adding following line to your struts.xml
设置简单的主题可以避免在表单中使用高级验证(我认为)。您应该使用 css_xhtml 模板,或者将以下行添加到您的 struts.xml
<constant name="struts.ui.theme" value="css_xhtml" />
<constant name="struts.ui.theme" value="css_xhtml" />
or specifically in concrete areas of your code, like form
或者特别是在代码的具体区域,比如表单
<s:form name="test" theme="simple">
<s:form name="test" theme="simple">
This way you get html elements with their css classes assigned, ready to be styled with css.
通过这种方式,您可以获得分配了 css 类的 html 元素,准备好使用 css 进行样式设置。