How to find the java class of the custom label and find the custom java

Source: Internet
Author: User
Tags tld

How to find the java class of the custom label and find the custom java

How to find the java class of custom labels

 

This is a reverse push process (creating custom labels can view the following connections: http://blog.csdn.net/antoniochan/article/details/38109905)

 

Run <company: ang filesMark = "$ {filesMark}"> </company: ang>

Example

Now you are looking

<% @ Taglib uri = "/xxx/xxxx/xxx. tld" prefix = "company" %>

 

Company is the name of this label, so you have to hit it first, but if you cannot find it, you may as well find it.

<% @ Include file = "/xxx/xxxx/xxx. jsp" %>

If there are many embedded pages, you need to find them one by one !!!

The path to the Tag Element "/xxx/xxxx/xxx. tld"

Find the element name ang In the tld.

<Tag>

<Name> ang </name>

<Tagclass> com. xxxxx. xxx. xx. x. xxxx. FileEdit </tagclass>

<Attribute>

<Name> filesMark </name>

<Required> true </required>

<Rtexprvalue> true </rtexprvalue>

</Attribute>

</Tag>

 

 

So <tagclass> com. xxxxx. xxx. xx. x. xxxx. FileEdit </tagclass>

 

Tagclass is the path of this label !!!!!!!!

 

 


How to Implement custom labels in java

First, write a tag Library Class, write a tld file, and configure it as required. Configure the resource file in config and add your tag to jsp.

For Java custom labels

TagSupport example:
Public class LangHuaTag extends TagSupport {
Private long startTime;
Private long endTime;

Public int doStartTag () throws JspException {
StartTime = System. currentTimeMillis ();
// Indicates the JSP page included in the custom tag
Return TagSupport. EVAL_BODY_INCLUDE;
}
Public int doEndTag () throws JspException {
EndTime = System. currentTimeMillis ();
Long elapsed = endTime-startTime;
Try {
JspWriter out = pageContext. getOut ();
Out. println ("runtime is" + elapsed );
} Catch (IOException e ){
E. printStackTrace ();
}
// Indicates that the JSP page continues to run
Return TagSupport. EVAL_PAGE;
}

}

Html code
<% @ Taglib prefix = "util" uri = "langhua.com/taglib/util" %>

<Util: timer> </util: timer>
<Util: loop times = "3">
<Util: date pattern = "yyyy-MM-dd"/> <br/>
</Util: loop>

Of course, you can write your own custom tag xml description file. We recommend that you read Sun weiqin's javaweb and tomcat. This is probably the title .. Haha

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.