Modify Struts2 default template Configuration

Source: Internet
Author: User
When developing a project using struts2, it finds that it always adds some html tags to the final html code, for example, using the <s: form> </s: form> tag, the generated html code is as follows:
<Form...> <table class = "wwFormTable"> </table> </form>
The blue highlighted part is automatically generated by struts. It is sometimes useful for these automatically generated items, but it is not suitable for some projects. For example, we cannot add table labels to all pages, or we need to use other style sheets and so on, so we do not want to generate these extra labels.
So how can we prevent struts2 from generating these labels?
In fact, in the struts-core-2.06.jar package contains some default template files, they are located under $ {struts-core-2.06.jar}/template, which has ajax, simple, xhtml and so on.
Check struts. properties. If not, view the $ {struts-core-2.06.jar}/org/apache/struts2/default. properties file, which has the following Configuration:
Struts. ui. theme = xhtml
Struts. ui. templateDir = template
Struts. ui. templateSuffix = ftl
This section describes the configuration of the struts2 template. You can modify the struts. properties file and change it
Struts. ui. theme = simple
Struts. ui. templateDir = template
Struts. ui. templateSuffix = ftl
If there is no struts. properties file, you can modify the struts. xml file and add the following lines to it:
<Constant name = "struts. ui. theme" value = "simple"/>
<Constant name = "struts. ui. templateDir" value = "template"/>
<Constant name = "struts. ui. templateSuffix" value = "ftl"/>
In this case, the html code generated by the <s: form> </s: form> tag is <form...> </form>.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.