Struts Framework Technology User Guide (1) (2)

xiaoxiao2021-03-06  49

MyResources_xx.properties - The same message containing the ISO language programming to "XX" (see the Java Document page for the ResourceBundle gets a current list). For the French version of the above news, you can have this entry:

Prompt.hello = Bonjour

You can have any of the resource package files you need. When you configure the Controller Servlet in the web application deployment, you need one thing that you need to define in an initialization parameter is the base name of the application's resource package. In the above case, this should be com.mycompany.mypackage.myResources. 3.3 Forms and FORMBEAN's interactive part of Web developers have established forms using HTML standard performance, such as use

mark. The user wants the interactive program to have a certain behavior. One of these expectations is related to the error handling - if the user has an error, the application should allow them to only modify the part you need to modify - without the need to retrieve the current page or form Any other information. Using standard HTML and JSP programming, this expectation is monotonous and heavy. For example, an input element of a username is like this (in JSP)

Value = "<% = loginbean.getusername ()%>>>

This is hard to knock your pair, you will make HTML developers without programming concepts, and will cause problems in the HTML editor. Instead, Struts provides a comprehensive mechanism based on JSP 1.1 custom tag library function to establish a form. The above situation uses Struts to handle the like this:

There is no need to explicitly involve JavaBean from which the initial value is obtained. This will be automatically processed by the frame. 3.3.1 Establishing a complete registration form using the Struts How to demonstrate how Struts greatly alleviates the pain of processing forms relative to JSP functions directly using HTML and standard. Consider the page called Logon.JSP (from Struts):

<% @ page language = "java"%>

<% @ Taglib Uri = "/ Web-INF / STRUTS.TLD" prefix = "struts"%>

<struts: message key = "logon.title" /> </ title></p> <p><body bgcolor = "white"></p> <p><struts: errors /></p> <p><struts: form action = "logon.do" Name = "logonform"</p> <p>TYPE = "org.apache.struts.example.logonform" /></p> <p><Table Border = "0" width = "100%"></p> <p><tr></p> <p><TH align = "Right"></p> <p><struts: message key = "prompt.username" /></p> <p></ tH></p> <p><TD align = "left"> <struts: text name = "username" size = "16" /></p> <p></ td></p> <p></ TR></p> <p><tr></p> <p><TH align = "Right"></p> <p><struts: message key = "prompt.password" /></p> <p></ tH></p> <p><TD align = "left"></p> <p><struts: password name = "password" size = "16" /></p> <p></ td></p> <p></ TR></p> <p><tr></p> <p><TD align = "right"></p> <p><struts: submit></p> <p><struts: message key = "button.submit" /></p> <p></ Struts: Submit></p> <p></ td></p> <p><TD align = "right"></p> <p><struts: reset></p> <p><struts: message key = "button.reset" /></p> <p></ struts: reset></p> <p></ td></p> <p></ TR></p> <p></ TABLE></p> <p></ struts: form></p> <p></ body></p> <p></ html></p> <p>The following entries are based on this example of the key feature of processing a form in Struts: TAGLIB instruction tells the JSP page compiler to find the tag library descriptor of the Struts tag library. In this case, we use Struts as a prefix to identify tags from this library, but you can use any prefix you want to use. This page uses several Message tags to find an international message string from a MessageResources object containing all resources of this application. In order to make this page work, the following message key must be defined in these resources: logon.title - Title of the registration page Prompt.userName - a "username:" prompt string Prompt.password - a "Password:" Tip String Button.Submit - "Submit" button Tag Button.Reset - The Tag of the "reset" button When the user registers, the application can save a Locale object in the user's session. This Locale will be used to select a message in the appropriate language. This makes it easy for the user to switch the user's option - only change the saved locale object, and all messages are automatically switched. Errors tag Displays any error message saved by a business logic component, or if there is no error message, it doesn't have anything. This marker will be described in depth below. FORM tag based on the specified property to an HTML</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-76742.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="76742" 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.125</b>, SQL: <b>10</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 = 'rPpMZfSigSWi5LKk0W_2F6dIXLjdjUOUpydEchQRVn6FAfk8wc1WbeJ_2F_2Fe8gah3NuUGQ0sP6hm2BNoqGfBc09VQA_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>