Improve development speed with label library

zhaozj2021-02-16  46

In order to make the development speed for easier and rapid development, Struts provides five label libraries similar to other JSP tag libraries, namely: HTML, Bean, Logic, Template and Nested. This series of articles describe the HTML tag library by three parts. The first part tells how to configure a Struts application to use this tag library and introduce the first group of labels; the second part tells the second set of labels; Part III takes an example to tell how to use this tag library. The premise of learning this series is that you have already had a basic understanding of Struts. If you don't know much, please read the series of articles I wrote about Struts (six parts). The HTML tag library is mainly used to display HTML elements. If you don't have this method, you must use the HTML tag to specify them. From the surface, this label library is simple. But through in-depth research, we will find it very powerful. For example, it can place a key content to generate JavaScript in a specific input element of an HTML form, or enter a verification generated script for the client. Moreover, you can use it to handle errors through a line of code. However, before you use this tag library for your Struts application, you need to do some simple preparations. Configure the application to use the tag library to configure a Struts application through three steps before using the Struts HTML tag library. 1. Register label in deployment descriptor (web.xml file): /web-inf/struts-html.tld / web-inf /struts-html.tld The code above told the Servlet Container about the situation of the Struts HTML tag library, and where to find the tag library TLD file. 2. Confirm that the struts-html.tld file is copied to the web-inf directory. You don't have to worry about label library class files because they are already included in the struts.jar file. 3. In each JSP page using the label library, insert the indicator: <% @ Taglib URI = "/ Web-INF / STRUTS-HTML.TLD" prefix = "html"%> In addition, you You can also use struts-html.tld files to learn what it supports the label and which properties can be brought by each tag. It is usually easy to use a custom label library: as long as you follow the steps described above. However, some tag libraries contain some principles that make us not so easy when using these labels. The Struts HTML tag library is one of them. Some tags are simple, easy to use; however, some labels depend on other tags or other elements in the Struts application. I am roughly divided into two categories in the HTML tag library: simple, easy to use tags, I call them "independent tags", and the second class is the label that must be used through a FORM label. I simply be simply called the second class of labels related to Form. This article mainly tells the independent label, and I will tell the form-related label in this series of articles. The HTML tag library contains several easy-to-use independent labels. Here, there are several important labels. Tags Tag is the easiest label in the HTML tag library. It has two properties: Locale and XHTML, both of which are not required.

The following code is selected from the JSP page using the tag: <% @ Taglib URI = "/ Web-INF / STRUTS-HTML.TLD" prefix = "html"%> Welcome </ title> </ head> <body> Hello World! </ body> </ html: html> Note that we have no standard <HTML> elements, but use <HTML: HTML> label. The first HTML refers to the prefix, the second is the <html> tag itself. And we also used the local property. The JSP page will be displayed: <html lang = "en"> <head> <title> Welcome </ title> </ head> <body> hello world! </ Body> <html> Note, <HTML: HTML LOCALE = "True"> The local property in the generated HTML page is converted into lang = "en". The resulting result depends on the locale of the server located at the Struts application. If you deploy an application to a different locale server, you don't need to change the code. Locale will automatically adjust. <base> Tags <base> Tag Displays an HTML element that represents the absolute position of the included JSP page with an HREF property. It is only valid when this tag is embedded in a Head tag portion. For example, this JSP page: <% @ taglib URI = "/ Web-inf / struts-html.tld" prefix = "html"%> <html: html locale = "true"> <head> <title> Welcome </ title > <html: base /> </ head> <body> Hello World! </ body> </ html: html> Convert to the following form: <html lang = "en"> <head> <title> Welcome </ Title> <base href = "http://www.domain.com/mystrutsapp/testing.jsp"> </ head> <body> Hello World! </ body> </ html> <img> tab <IMG> tab Used to generate an HTML <IMG> tag. Its most important attributes are: • Page: Image file relative to the path of the module; you must have a slash. · Height: The height of the image. · Width: The width of the image. · Alt: If the image is not found, the text is displayed.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-22756.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="22756" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.039</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '46NL_2FwVuWgPq_2BCNN9K6vlcKHdLZohSV_2F7idKaGYxwhSX2j8xp4OsKSjFU7vunRJs_2FOmr2AHGTVlBjhMu9hOjHg_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>