Label Attribute, label attribute

Source: Internet
Author: User

Label Attribute, label attribute

Put a label on a class to indicate certain rules. For example, if a certain attribute of an object does not want to be converted into json, you can just put a label on it, or specify the table name corresponding to a Class during ORM.

 

Finally, labels are called through reflection. A class can be used as a label as long as it inherits Microsoft's Attribute class.

 

[AttributeUsage (AttributeTargets. all)] // specifies the range of Attribute usage. For example, you can only use public class Column: Attribute {public Column (string str) {this. str = str;} public string str {get; set ;}// 2nd [AttributeUsage (AttributeTargets. all)] public class Table: Attribute {public Table (string str) {this. str = str;} public string str {get; set ;}// two attributes [Column ("class")] [Table ("table class")] public class Abc {public string x {get; set;} [Column ("attr")] public Int32 y {get; set ;}} protected void Page_Load (object sender, eventArgs e) {// the attr Type = typeof (Abc) On this type can be called through reflection );
Bool isGot = Attribute. isDefined (type, typeof (Column); // check whether there is a certain Attribute [] attrs = Attribute. getCustomAttributes (type); // obtain string xy = attrs in batches. first (). getType (). name; // you can check its Name to select the desired Name or to see if it is needed. column column = (Column) Attribute. getCustomAttribute (type, typeof (Column); // forced conversion of Column [] columns = (Column []) Attribute. getCustomAttributes (type, typeof (Column); column = columns [0]; string x = column. str; // call methods or make public attributes. // after instantiation, Abc a = new Abc () can also be used. PropertyInfo info =. getType (). getProperty ("y"); Column attribute2 = (Column) Attribute. getCustomAttribute (info, typeof (Column); string xyz = attribute2.str ;}

 


What is the attribute object of CSS/HTML code?

The tag attribute or attribute of an HTML element in the form of an object. The table below the member table lists the members drawn from the attribute object. Click the label on the left to select the member type you want to view. Label attribute/attribute SHOW: Label attribute/Attribute Set Method label attribute description expando setting or obtaining the value indicating whether any variable can be created in the object. FirstChild gets the reference of the first child object in the childNodes set of the object. LastChild obtains the reference of the last child object in the childNodes set of this object. Set or retrieve the object name. NextSibling gets a reference to the next sibling object of this object. NodeName gets the name of a specific node type. Obtain the type of the required node from nodeType. Set or obtain the node value. OwnerDocument sets or obtains the document Object associated with the node. ParentNode obtains the parent object in the document level. Previussibling gets a reference to the previous sibling object of this object. Specified checks whether this attribute is specified. Set or obtain the object value. The annotation attribute object can be accessed through the attributes set. A valid tag attribute or attribute can be any dynamic HTML (DHTML) attribute or event applied to the object, or an extended attribute. This element is in Microsoft ?? Internet Explorer 5.0 scripts are available. In this example, the attribute object is used to create a specified attribute list.

Jsp + servlet question: the servlet sets requestsetAttribute ("product", proList); which tag is used to retrieve the jsp page?

The upstairs solution is complete. Supplement
<%
List proList = (List) request. getAttribute ("product ");
For (ProductBean pb: proList ){
%>
<Table>
<Tr>
<Td> <% = pb. getName () %> </td> <! -- Display the name in this cell -->
<Td> <% = pb. getPrice () %> </td> <! -- Display the price in this cell -->
............
</Tr>
</Table>
<%
}
%>
This should be the most complete. Even the table is added to you.

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.