Configure Package namespaces
Implementing an action requires that you configure the action in struts. First configure the package properties:
It is important to note that when a frame is matched for a package, it is matched from top to bottom in the document.
<!--The package named Book is configured below, which inherits the default package for struts 2. Specifies that the package's namespace is/book-->
1 <package name=" Zjj.controller "extends =" Struts-default "namespace="/book "> 2 3 <!--Configure an action--> 4 5 <action name= "getbooks" class= "Zjj.controller.Book" > 7 &L T;result name= "Bookdetail" >/web-inf/content/bookdetail.jsp</result> 8 9 </action>10 11 </package ;
<!--The package named Zcx.controller is configured below, which inherits the default package for struts 2
No namespace is specified, the default namespace is used--
1< PackageName= "Zcx.controller" namespace= "/"extends= "Struts-default" >2 3<action name= "Login"class= "Zcx.controller.LoginAction" >4 5<result name= "Success" >/WEB-INF/content/welcome.jsp</result>6 7</action>8 9<!--to handle all action-->Ten One<action name= "*" > A -<!--return the corresponding page-- - the<result>/WEB-INF/content/{1}.jsp</result> - -</action> - +</ Package>
Struts2-Learning Note Series (5)-Configure action