I. default values in action configuration
<Span style = "font-size: 18px; "> <package name =" itcast "namespace ="/test "extends =" struts-Default "> <action name =" helloworld "class =" CN. itcast. action. helloworldaction "method =" execute "> <result name =" success ">/WEB-INF/page/hello. JSP </result> </Action> </package> 1> if no class is specified for action, actionsupport is used by default. 2> if no method is specified for the action, the execute () method in the action is executed by default. 3> If the name attribute of result is not specified, the default value is success. </Span>
Ii. Various forwarding types of result in action
<Span style = "font-size: 18px;"> <action name = "helloworld" class = "CN. itcast. action. helloworldaction "> <result name =" success ">/WEB-INF/page/hello. JSP </result> </Action> the result configuration is similar to the forward in struts1, but struts2 provides multiple result types. Common types include DISPATCHER (default), redirect, redirectaction, and plaintext. You can also use the $ {attribute name} expression in result to access the attributes in action. The attribute names in the expression correspond to the attributes in action. <Result type = "Redirect">/view. jsp? Id =$ {ID} </result> the following example shows the redirectaction result type. If the redirected action is in the same package: <result type = "redirectaction"> helloworld </result> If the redirected action is in another namespace: <result type = "redirectaction"> <Param name = "actionname"> helloworld </param> <Param name = "namespace">/test </param> </result> plaintext: display the content of the original file. For example, you can use this type when you need to display the source code of the JSP file as is. <Result name = "Source" type = "plaintext"> <Param name = "location">/xxx. JSP </param> <Param name = "charset"> UTF-8 </param> <! -- Specify the encoding of the file to be read --> </result> </span>
[Struts2 Study Notes (2)] default values in action configuration and various forwarding types of result in action