JSTL Base simpletagsupport Custom Label label Body Scriptless

Source: Internet
Author: User

Li Wu:
Good study and thinking, honouring teachers save Thanksgiving. Leaf See root three return to one, rivers the same oneness.
Meekness Conscience Lord, willing to do without regrets to the most bitter. Reading exercise strong body and mind, Prudential advised and the line and cherish.



Javaee:7
javase:1.8
jstl:1.2.2
Server:tomcat 8.5
Browser:chrome/firefox
Os:windows7 x64
Ide:myeclipse



Project structure

Jizuiku-tags.tld

<?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 ">    <tlib-version>1.0</ tlib-version>  <short-name>jzk</short-name>  <uri>http://www.jizuiku.com/tags/1.0 </uri>        <!--configuration Tab--  <tag>  <name>MyDecorationTag</name><!-- Specify the name of the current label-  <tag-class>com.jizuiku.tag.MyDecorationSimpleTagSupport</tag-class><!-- The current label's handling class-  <body-content>scriptless</body-content><!--Specifies the type of tag body el expression--  </ Tag>  </taglib>

Mydecorationsimpletagsupport.java

Package Com.jizuiku.tag;import Java.io.ioexception;import Java.io.writer;import javax.servlet.jsp.JspException; Import javax.servlet.jsp.tagext.simpletagsupport;/** * Decorate the contents of the label, to a box ah what * *  @author Blog Park-to the most bitter  * @version V2017.12.04 */public class Mydecorationsimpletagsupport extends simpletagsupport{@Overridepublic void Dotag () throws Jspexception, IOException {//TODO auto-generated method Stubwriter out = This.getjspcontext (). Getout ();//This was written in the past, The effect of the output is also on//Out.write ("<div class= ' Commondiv ' >");//But the value of the most bitter feeling class is wrapped up in double quotation marks//So, using escape ... It's just a little episode, Hey ... Programming Fun Out.write ("<div class=\" commondiv\ ">");//The execution result of the El expression is given to the out stream This.getjspbody (). Invoke (out); Out.write (" </div> ");}}

myjsp.jsp

<%@ page language= "java" import= "java.util.*" pageencoding= "UTF-8"%><%@ taglib prefix= "C" uri= "/HTTP/ Java.sun.com/jsp/jstl/core "%><%@ taglib prefix=" J "uri="/web-inf/tlds/jizuiku-tags.tld "%><%String Path = Request.getcontextpath (); String basepath = request.getscheme () + "://" + request.getservername () + ":" + request.getserverport () + path + "/";%>& lt;! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >

Browser view

The source code for this page

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >

Learning resources: Itcast and Itheima Video library. If you have public resources, can share to me, with your resources to learn also can.
Blog post is to watch the video, into thinking written. It's good that the teacher speaks well. Blog bad, is to give the most bitter not serious.

JSTL Base simpletagsupport Custom Label label Body Scriptless

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.