Spring

xiaoxiao2021-03-06  67

Spring is an Application Framework that serves all levels: provides the BEAN configuration foundation, AOP support, JDBC's extraction framework, abstract transaction support, and so on. It has a very significant feature: at a level if you don't need Spring support, you can use the string Class, only the features of some part of it. From its design concept, you can see String Help you implement the true logical layer and the WEB layer separation. For EJB, Spring is a lightweight J2EE application development framework. The lightweight referred to here is the Spring framework itself, not that Spring can only apply to lightweight application development. Spring's lightweight is reflected in its frame itself, and the support and assembly capabilities of other application tools, Spring makes us reduce the risk between the technical levels compared to EJB's homonomer. EJB has strong cohesiveness, such as data persistence layer management, transaction management, and lifecycle management are all handed over to the management of the EJB container. The white box characteristics of the cohesiveness allows us to give up a part of the controllability to trust the container capacity. . Spring is considering how "not built wheels", how to better assemble these wheels, let them turn better. For example, data persistence layer management can use Hibernate, log management can use JakartacomMonLogging. A more appropriate metaphor is "We have to get a few nails. In order to accomplish this, the hammer producer produces a large and small series of hammers, each with a complex method of use, used to nail a special Nail, the result makes us headache. Solve the problem of excessive hammer, through Spring, we can use several hammers, but it is like only one hammer. " (Note: This paragraph is visible online. Here is this metaphor. I personally feel very vivid) There are also some simple summary on this framework: "Spring has several major parts: bean ApplicationContext, with a unified , IoC's way, manage, assemble, use the system components, replace all plants; persistence framework; web framework. "J2EE Framework" is the vision of Rodjohnson, he hopes that Spring provides the top to the J2EE lightweight solution Comprehensive infrastructure support. "Well, the above is a brief introduction to a new Framework, is said to be the direction of J2EE development. Previously on the discussion of J2EE's best combination, I heard that this JSTL STRUTS (or webwork) Spring Hibernate is very optimistic (the view is different, just for reference, huh), if you are interested, You can take a look at the Springframework Chinese Forum. The topic of this article is transferred below. Spring tag library introduction and usage: This article will focus on the tag library provided by Spring and its usage: When you use Spring Framework in the project, the performance layer can select the Spring Framework's own tag library. Of course, this is not your only choice. You can choose other tag libraries or template replacement techniques. Spring Framework does not provide a very rich tag library for applications. The marker library provided by Spring Framework is just to use it, it is not unpacking. Oh, this is different from the Struts rich tag library. In fact, this is in line with the starting point of Rodjohnson, which is both "no wheel". Of course, the Spring Framework tag library has its own characteristics, it can be said to be a good supplement. The Spring tag library is classified as follows: 1. Spring: HasbinderRors 2. Spring: BIND 3.

Spring: Transform 4. Spring: Message 5. Spring: HTMLESCAPE 6. Spring: Theme Let's take a specific use: 1. Spring: HasbinderRors corresponds to the org.springframework.web.servlet.tags.binderrorseTag tag library processing class. This tag provides an Errors for binding objects. If this tag is used, the error on this object will be displayed on the page. The prerequisite for using this tag is to use the tag, and this tag cannot be used to represent the status of the object, which can only bind the object itself and the object of the object. The specific usage is as follows: please fix all errors! Through this simple example, I will tell the properties of this tag. Name: It is the name of the bean to be checked. This attribute is required. Oh, here is a simple usage, so don't introduce the Erroors variable it contains. Specific English documents. Same. 2. Spring: BIND corresponds to the org.springframework.web.servlet.tags.bindtag tag library processing class This tag is used to assign a value for a bean or bean, usually used with Form, which is equivalent to the action of Action. It indicates that the form is to be submitted to the attribute of that class or class. Where the Path property is a must, specify the path to the class. Examples:

increase (%): >
...................... 省 < 3.

Spring: Transform corresponds to the org.springframework.web.servlet.tags.transformTag tag processing class, which is used to convert those properties that are not in one by one in the form in the form, usually and . Tagged as Using better support. The property is as follows: Value: It must be required. The same as the BEAN class pointing to the current tag. It is the entity class name you want to convert. VAR: is not required. This string is used to bind output results to page, request, session, or Application Scope. The default is output to JSP. Scope: It is not required. Prerequisites VAR must be set. Its value can be Page, Request, Session, or Application. 4. Spring: Message corresponds to org.springframework.Web.Servlet.tags.MessageTag Tags Processing class This tag is used to help SpringFramework supports internationalization. Similar to JSTL's FMT: Message tag. Of course, this tag can work well under the local SpringFramework framework. The property is as follows: Code: It is not required. Used to find Message, when not used, Text will be used. TEXT: It is not required. If Code does not exist, the default is the text output. When Code and Text are not set, the tag will output to null.var: not required. This string is used to bind output results to page, request, session, or Application Scope. The default is output to JSP. Scope: It is not required. Prerequisites VAR must be set. Its value can be Page, Request, Session, or Application. 5. Spring: htmlescape corresponds to org.springframework.web.servlet.tags.htmlescapeTag tag library processing class is not commonly used, here is omitted 6. Spring: Theme corresponds to org.SpringFramework.web.servlet.tags.Themetag tag library processing class is not common, omitted haha, after learning these usage, let us look at a specific example. The configuration steps are as follows: Directory Structure Figure: -spirngapp -Web-inf-Classes -Lib -Src -war1. Copy Spring.TLD to the web-inf directory. 2.

For example, copy the spring.jar to the web-inf / lib package as follows: Configure the taglib property in web.xml, the code is as follows: springapp org.springframework.web.servlet.dispatcherservlet 1 SpringApp *. htm Index.jsp / Spring /web-inf/spring.tld JSP page code as follows: <% @ include file = "/ web-inf / jsp / include.jsp"%> <% @ Taglib prefix = "Spring" URI = " / Spring "%> <fmt: message key =" title "/> </ title> </ head> <body> <fmt: message key =" priceIncrease.Heading " /> </ h1> <form method = "post"> <TABLE Width = "95%" border = "f8f8ff" border = "0" cellspacing = "0" cellpadding = "5"> <tr> <TD alignment = "Right" width = "20%> increase): < / TD> <spring: bind path = "priceincrease.percentage> <td width =" 20% "></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-120081.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="120081" 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.058</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 = 'MgtczPT5iS9kmrQDzL6C55q6SBxU_2F7d_2Fg9G4WQDEV5ds24hsEUdBUr1yWyhDxNVFTt6L2AQJ4xClB1FHkR2M4A_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>