Introduction to the development steps of international Struts

xiaoxiao2021-03-31  189

1. Download Struts can be downloaded by http://jakarta.apache.org/struts/index.html download, download it after downloading it. War files to Tomcat's WebApps directory, start Tomcat, if http: // localhost : 8080 / Struts-Example / There is no problem in running, indicating that the environment is established; 2. Establish an engineering to create an international folder in the webapps directory, and then establish a web-INF folder and web-inf / class folder in the International directory;

3. Plus Struts class and Struts tab Definition file (1) Create a lib sub-directory in the web-inflicity, copy all the .jar files in the Struts-Example / Web-INF / LIB directory to this directory; These files are Struts's control class libraries and label class libraries. Commons-beanutils.jar Commons-Collections.jar Commons-Digester.jar Commons-fileupload.jar Commons-lang.jar Commons-logging.jar Commons-Validator.jar Jakarta -oro.jar struts.jar (2) Under the struts-example / web-infrink, copy the .tld file to the INTERNATIONAL web-inferity, these file tag definition files; struts-bean.tld struts- HTML.TLD STRUTS-LOGIC.TLD STRUTS-NESTED.TLD STRUTS-TEMPLATE.TLD STRUTS-TILES.TLD 4. Create struts-config.xml and web.xml file (1)

The Resources.Application Table is the resources directory under the classs directory to store resource files. The default language file is named Application.properties, Chinese is Application_ZH_CN.Properties, other languages ​​are similar;

(2)

test international action org.apache.struts.Action.ActionServlet config / web-inf / struts- Config.xml debug 2 Detail 2 2 action *. Do < Welcome-file> index.jsp / tags / struts-bean / web-inf /struts-bean.tld

/ tags / struts-html /web-inf/struts-html.tld / tags / struts- Logic /web-inf/struts-logic.tld / tags / struts-nested /web-inf/struts-nested.tld / tags / struts-tiles /web-inf/struts-tiles.tld 5. Creating a resource file (1) Under the CLASSES directory, create a resources directory, used to store resources Document; first establish a default resource file Application.properties and English (US) resource file application_en_us.properties, content: # - international test - test.title = international application = this is a threeational application Test.Body = this is a international application test test test test test TEST.BODY =

(2) Create an application_cn.properties in the resources directory, enter the content:

# - International test - test.title = Internationalization program test Test.body = This is an international program test example

Because Java's internationalization is implemented through the Unicode code, so turn the code into a Unicode code; under DOS, go to the resources directory, execute:

Native2ASCII Application_cn.properties Application_ZH_CN.Properties

Converted Application_ZH_CN.Properties file content: # - International test - test.title = / u56fd / u9645 / u5316 / u7a0b / u5E8f / u6d4b / u8bd5 test.body = / u8FD9 / U662F / U4E00 / U4E2A / U56FD / U9645 / U5316 / U7A0B / U5E8F / U6D4B / U8BD5 / U4F8B / U5B50

(3) Create an application_tw.properties in the resources directory, and perform similar operations 6. Create a JSP file in the International directory, establish an index.jsp file, content: <% @ page contenttype = "text / html; charset = utf -8 "%> <% @ Taglib URI =" / tags / struts-bean "prefix =" bean "%> <% @ taglib URI =" / tags / struts-html "prefix =" html "%> <% @ Taglib Uri = "/ tags / struts-logic" prefix = "logic"%> <bean: message key = "test.title" /> </ title > <Html: base /> </ head> <body bgcolor = "white"> <p> <bean: message key = "test.body" /> </ p> </ body> </ html: html> 7 .</p> <p>Test multilingual Open IE "Tools" -> "Internet Options" menu, "General" tab, click on "Language" button, add "English (US) - [EN-US] language, will other languages Delete, after restarting IE, type http: // localhost: 8080 / international / index.jsp, you will find that the content has become English; use the same method, you can test Simplified Chinese and Traditional Chinese;</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-130821.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="130821" 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.048</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 = 'u5Yrn31YM45LdVniIE8AHVlQXTIefdEZJ7fQLoleCLBjfiQhyjetVWiXqjsCV_2BMEpSoZqpOtfDFLlP6c'; 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>