How to disable struts 2 Table generation for Form?

前端 未结 4 749
遇见更好的自我
遇见更好的自我 2020-12-30 00:46

Struts 2 automatically generate HTML table for it\'s tag. How can I disable it? Any help will be appreciated. Thank You.

相关标签:
4条回答
  • 2020-12-30 01:12

    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

    <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" />
    
    0 讨论(0)
  • 2020-12-30 01:21

    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

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

    or specifically in concrete areas of your code, like form

    <s:form name="test" theme="simple">

    This way you get html elements with their css classes assigned, ready to be styled with css.

    0 讨论(0)
  • 2020-12-30 01:22

    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.

    0 讨论(0)
  • 2020-12-30 01:29

    Another possibility would be using the usual HTML tag.

    0 讨论(0)
提交回复
热议问题