Struts2 label library usage Summary

Source: Internet
Author: User

Some struts2 labels were used in the previous demo, using struts2.2.1.1.

Struts2 labels are often used with OGNL (Graphic object Navigation language. The following is a summary:

1. Required jar packages for struts2 labels
The struts2 tag can be divided into data tag, control tag, form tag, AJAX tag, and so on. To use these tags, you must add the following jar packages to the web project:

Commons-codec-1.6.jar


Commons-fileupload-1.2.1.jar


Commons-io-1.3.2.jar


Commons-logging-1.1.1.jar


Freemarker-2.3.16.jar


Ognl-3.0.jar


Struts2-core-2.2.1.1.jar

Struts2-dojo-plugin-2.2.1.1.jar

Xwork-core-2.2.1.1.jar

The struts2-dojo-plugin-2.2.1.1.jar contains the struts2 ajax topic template, the others are required by struts2.2 jar package

2. struts2 labels and filters
The struts2 tag can be used only in the requested resources (jsp or action view) filtered by the strtus2 core filter. Therefore, to use the struts2 tag on a jsp page that does not return a view as an action, you must configure web. xml to make the struts2 filter valid for all requests:


[Html]
<Filter-mapping>
<Filter-name> struts2 </filter-name>
<Url-pattern>/* </url-pattern>
</Filter-mapping>

<Filter-mapping>
<Filter-name> struts2 </filter-name>
<Url-pattern>/* </url-pattern>
</Filter-mapping> 3. ajax tag

If ajax tags are used, in addition to referencing the struts tag Library at the beginning of the jsp page:

<% @ Taglib prefix = "s" uri = "/struts-tags" %>

In addition, you also need to add

<S: head theme = "ajax"/> (the subsequent ajax labels use the s prefix)

Or add a reference to the dojo tag Library at the beginning of the page.

<% @ Taglib prefix = "sx" uri = "/struts-dojo-tags" %> (ajax labels on the subsequent page use the sx prefix)

4. Limitations of the struts2 tag Library
The struts2 tag library is not omnipotent. For example, it is difficult to use multiple combobox tags with different names in a form. If necessary, you must write your own js implementation.

 

Related Article

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.