Learn struts

zhaozj2021-02-12  210

It has been developed with Struts for a while, I always feel that it is not very profound for Struts, but because of the project tight, there is no time to study carefully, and now there are some small problems, and I really hope that the company has passed the difficult relationship). Our project is also Basically, I want to study struts carefully, first start from the example from Struts.

When I started to get in touch with Struts, I was developed with other companies. I didn't have any concepts at the time. I didn't have used Java. It is really a deficiency. At that time, there was a Struts master. I want to study hard with him, but for some reason, he withdrew us for 2 weeks, with us, with us, only give us a head, I can only learn.

When you start contact, you have used some simple things in it. Some of the basic Sturts's HTML tags, and the most is the logic: Iterate tag, this thing is used to do loops, or is very convenient. Other HTML and Java code instead, it also holds some JSP Javabean's intrigue. Today, I read the code in Struts. The code on the feeling is very clean. It seems that there are still many things worth learning in Struts. s things.

Let me talk about the bean: Message tab. With this thing, it is true. You can use this tag on the page, and the actual content is written in the formulation file. If you do not modify the code, you can change the text on the page, which is convenient. The label can be shared in each page, the biggest advantage is that it can be easily realized, which can automatically display the text on the interface according to different clients.

Definition in the struts-config.xml file

This can be used. Org.apache.struts.Webapp.example.ApplicationResources is the path to the resource file, the suffix is ​​Propreties, the default file is ApplicationResources.properties, if you want to implement the Chinese interface, then make an ApplicationResources_zh.propreties file is OK. Start, in the example in Struts, I saw the resource files of several other countries. They are a bunch of similar / U041F / U043E / U0434 / U04440 / U0434 / U0438 / U0442 / U044c things, I don't know why it is like this. I remember that we were developed to write Chinese directly in the file. I tried it, no, it is garbled, converted with the Native2ASCII tool, I can't understand. Later, I found that all the pages in StURTS use UTF-8, so we need to write / u ****, we use ISO-8859-1, so you can write Chinese directly, try it, As so much.

Now let's try it, first restart Tomcat, restart Tomcat. The reason why Tomcat is restarted because this mechanism is implemented through the session, and the session records the language information recorded when the user is first accessed, and the session information can be restarted. Then Modify IE-> Tools -> Internet Options -> General -> Language -> Delete the default Chinese, add EN_US, and determine. If you visit the pages just now, you can see the English page. Access on another Chinese system, seeing is still the Chinese interface.

转载请注明原文地址:https://www.9cbs.com/read-7337.html

New Post(0)