STRUCTS - Tag Library (Bean) - - - -
The bean tag library This label library and Java beans have strong relevance, and the design is intended to provide an interface between JSP and JavaBean. Struts offers a small suitably useful label library to manipulate JavaBean and related objects: Cookie, Header, Parameter, Define, Write, Message, Include, Page, Resource, Size, Struts.
BEAN: Cookie, Bean: Header, Bean: Parameter These three labels are used to re-get cookie, Request Header, and Request Parameter. Bean: Header and Bean: Parameter tab defines a string; bean: cookie tab defines a cookie object. You can use the Value property as the default. If you can't find the specified value, and if the default value is not set, you will throw an Request Time anomaly. If you expect to return multiple values, you can set the multiple property to True.
The following code outputs some properties of some cookie objects:
<% Java.util.enumeration name = (httpservletRequest) Request .getHeadernAmes ();%> ... <% while (names.hasmorelements ()) {string name = (String) Names.nexTelement ();%>
you are viewing this page with:
Welcome
Bean: Define: There are three uses. First, define new string constants:
The second is to copy an existing bean to the new bean:
The third is to copy an existing bean property to the new bean:
Bean: incrude
This tag and bean: include labels and similar, different points are it defined a script variable that can be multiplexed. Name a new script variable with ID attribute, but also support forward, href, page, and transaction, and HTML: Link properties in the Link.
Bean: Message
Used to implement a label for internationalized support, with the Locale and ResourceBundle classes defined in the java.util packet to complete this task, with the Java.Text.MessageFormat class configuration message.
First, you want to specify the name of the resource file. This file contains all messages that will appear in the program with the default language, which are stored in the "Keyword-Value". The file needs to be stored under the classpath and the path is to be transmitted to the ActionServlet as an initialization parameter.
Implementation of internationalization: All resource files must be stored in the directory where basic resource files are located. The basic resource file contains messages written in the local language in the default regional language - local language. If the name of the basic resource file is ApplicationResources.Properties, the name of the resource file written in other specific languages should be ApplicationResources_xx.properties (xx is ISO code, such as English is en). So these files should contain the same keyword, but the value of the keyword is written in a particular language.
Then, the area initialization parameters of the ActionServlet must be transmitted with a TRUE value so that ActionServlet stores a regional object of a particular user computer under an action.locale_key keyword in a user session. You can now run an international Web site that automatically displays in accordance with the area on the user's computer.
Replace some messages using a specific string:
Definition in the resource file: info.mykey = The number {1}, {2}, {3}, {3} tag:
BEAN: Page: Take internal objects in JSP as script variables.
Bean: size: Get the number stored in Array, Collection or Map, the type is java.lang.integer.
Bean: Struts: Copy the Struct object (three types) Give new beans, scope is Page.
Bean: Write: outputs the property value of the bean in a string.
Filter property: When set to true, convert the HTML reserved word to an entity ("<" converted to & lt);
Ignore properties: If the object does not exist, no exception will be thrown.