Today accidentally looked at the Struts2.0, the results found that it and Struts1.1 have a great change, can be said to have changed beyond recognition. As a programmer, and must master the latest technology, therefore, it is an upgrade, we have to follow the study, it is not too bitter! But Prito cover soldier to Will block, you have the Dragon 18 Palm, I have the universe big move, we see recruit the recruit, status quo, the Mountain king or the Spider Jing, in my eyes, is a pile of bones!
The first thing to note is that it's best not to abuse struts tags in web development--HTML tags are used as much as possible with HTML tags, such as some of the most basic page objects such as Button,radio,label,text,textarea,table,form, Select,submit and so on, unless some HTML tags do things, such as logical judgment, traversal, comparison, and so on, you need to use the struts tag. In addition, to populate the view with data, you must also use the struts tag, such as: (This is the label in the struts1.x version, do not know what is in struts2.x?) )。
In this way, if you need to migrate from the struts1.x version to the struts2.x version, there is no need to make drastic changes to the page. In fact, I have developed so many sites, have not found the HTML tags do not do things (of course, to remove some of the need for the background logic to deal with things, but as long as it is purely for display, HTML tags are sufficient!) ) 。
This point of view for struts learning also has a certain guiding significance: Struts replacement speed is very fast, if we have to learn everything, it is not all day to pay attention to it? Therefore, for the study of struts, just focus on the following 5 aspects:
(1) Tag Library of learning: As mentioned above, struts tag Library of the label also has a good dozens of, we do not need to go to one of the learning, just need to learn the server (or so-called background) for logical processing of the struts tag, For those labels that can be explained directly by the browser (that is, the so-called front desk), such as button,text,font,table,radio,form,select ..., it is best not to use the struts tag instead. In this way, Struts label learning can be less than 4/5 of the amount of learning!
(2) Action Class Learning: Action is always the core of the struts framework, it is responsible for page rendering, so need to deal with the middleware, and therefore, it is connected to the struts framework and other layers of the hub. With the foundation of struts1.x, learning struts2.x action will be easy to master. Therefore, for the Programer with Struts Foundation, this part of the study is quite easy, a little bit to see.
Note that if you learn struts2.x directly, you may not know the Formbean component in struts1.x. The suggestion is to try to get a better understanding of these, which will help you understand more deeply how the struts framework works.
(3) Struts-config.xml configuration file: This is the core of Struts-controller. The page jumps, the view data transmits all relies on it to control and the command. struts1.x, you need to focus on understanding and the principle, at the same time will use global forwarding, OK! But in struts2.x, because the view data is encapsulated in the action, I don't know how it needs to be configured. But as long as mastered the struts1.x configuration, struts2.x is not a problem, a little look at the understanding.
(4) The collaboration between Struts and spring: it seems that the IOC is built into the struts2.x, but as its publisher puts it: the ability to implement IOC with spring is to use spring as much as possible. So, no matter how struts upgrades, Spring has to be mastered.
(5) Struts and hibernate collaboration: As a classic SSH combination, using struts and spring, how can you leave the hibernate? As long as the previously configured hibernate programer, no matter how struts upgrade how to disguise, hibernate configuration is almost the same, not because struts change will become difficult.
In summary, in fact, when learning a new version of struts, we only need to understand its tag library, action and configuration, and the tag library needs to know only a few logical functions of the tag is enough. Of course, if you give up HTML completely and have to use the Struts tab, take a little more time to look at it.
The difference between Struts2.0 and struts1.x
However, in addition to the top three core and basic requirements, there are some other improvements to the new version of Struts, which I found on the internet, It makes some comparisons to the Struts2.0 in struts1.x, and if you look at it, you will understand why struts upgraded (nothing more than to make it better):