Java Custom Label Pass value

Source: Internet
Author: User

<?xml version= "1.0"  encoding= "UTF-8"  ?> <taglib xmlns= "http://java.sun.com/ Xml/ns/j2ee "    xmlns:xsi=" Http://www.w3.org/2001/XMLSchema-instance "     xsi:schemalocation= "http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ Web-jsptaglibrary_2_0.xsd "    version=" 2.0 ">    <!--  Description used to add a description of the Taglib (tag library)  -->    <description> The custom tag library developed by Aloof Wolf </ description>    <!--taglib (Tag Library) version number  -->    < tlib-version>1.0</tlib-version>    <short-name>gacltaglibrary</ short-name>    <!--          Set a Uri,uri to/from the custom tag library, and/or the following, as/gacl ,         in the JSP page when referencing the tag library , you need to find the tag library by Uri          in the JSP page.Sample Introduction Tag library: <% @taglib  uri= "/gacl"  prefix= "GaCl"%>    -->     <uri>/gacl</uri>    <!--a taglib (tag library) contains multiple custom labels, each of which uses a tag tag to describe   -->    <!--  A tag tag corresponding to a custom label  -->      <tag>        <description> The purpose of this tag is to output the IP address of the client </ description>        <!--               label Processor class with a label name, when using a tag in a JSP page, the tag name is used to locate the tag processor class to be called               can find the corresponding Me.gacl.web.tag.ViewIPTag class by Viewip           -->        <name> viewip</name>        <!--  Tag corresponding processor class-->         <tag-class>cn.springmvc.controller.viewiptag</tag-class>         <body-content>jsp</body-content><!-- empty  or  -->          <attribute><name>userName</name><required>true</required><rtexprvalue>true</rtexprvalue></attribute>    </tag> </taglib><xdp:viewip username= "John1231"  > add </xdp:viewip> package cn.springmvc.controller;import java.io.ioexception; import  javax.servlet.http.HttpServletRequest;import javax.servlet.jsp.JspException;import  Javax.servlet.jsp.jspwriter;import javax.servlet.jsp.pagecontext;import javax.servlet.jsp.tagext.tag ;p ublic class viewiptag implements tag  {     // Receive PageContext objects passed in     private PageContext pageContext;     private string username;     @Override     public int  doendtag ()  throws JspException {         System.out.println ("Call Doendtag () method");        return 0;     }     @Override    public int dostarttag ()  throws JspException {         system.out.println ("Call doStartTag () method");         system.out.println (UserName);         httpservletrequest request = (HttpServletRequest)  pagecontext.getrequest ();         jspwriter out = pagecontext.getout ();     &NBSP;&NBSP;&NBSP;&NBSP;STRING&NBSP;IP&NBSP;=&NBSP;REQUEST.GETREMOTEADDR ();         try {            // Here the output will throw IOException exception             out.write (IP);             out.write ("

Java Custom Label passing value

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.