1.struts2.x povides features to reduce xml configuration via intelligent defaults,utilizes
annotations and provides conventions over configuration.Actions are now POJOs which increases
testability and reduces coupling in the framework, and HTML form field data is converted to proper
types for the action to use.
2.Struts2 is a pull-MVC (or MVC2)framework; this is slightly different from a traditional MVC
framework in that the action takes the role of the model rather than the controller, although there
is some overlap.
3.The struts.properties configuration file provides a mechanism to change the default behavior of
the framework.
4.A familiar technique for most web developers is to place the object that needs to be accessed in
the HttpServletRequest or the HttpSession. This can be achieved by implementing the “aware”
interface (letting the dependency injection to do its work) and then setting the object to be
accessed under the required name.
5.The value stack is exactly what it says it is – a stack of objects. OGNL stands for Object Graph
Navigational Language, and provides the unified way to access objects within the value stack.
6.
<action name=”*/*” method=”{2}”
class=”com.infoq.actions.{1}Action”>
<result type=”redirect”>/{1}/view.action</result>
<result name=”view”>/{1}/view.jsp</result>
<result name=”input”>/{1}/edit.jsp</result>
<result name=”home”>/{1}/home.jsp</result>
</action>
The action will need to extend the ActionSupport class (providing validation and error message
handling implementations) and implement the ModelDriven and Preparable interfaces. The interceptor
stack along with the two interfaces is the key to making the implementation easy, so let’s
take a look at those in more detail.
也可分开来定义:
<action name="List" class="tutorial.action.BookAction" method="list">
<result>List.jsp</result>
</action>
//list是BookAction中的一个方法.
7.上传文件时要用到
commons-fileupload-1.2.jar
commons-io-1.1.jar