Struts2 learning process -struts Executive Brief

1.web.xml

<web-app>
    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>
            org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
        </filter-class>
    </filter>

    <filter-mapping>
        <filter-name>struts2</filter-name>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>REQUEST</dispatcher>        
        <url-pattern>/*</url-pattern>
    </filter-mapping>

</web-app>

All access will be intercepted fliter filter, which struts into the workflow of them.

 

2.struts.xml

<action name="addProduct" class="com.how2java.action.ProductAction"
            method="add">
            <result name="list" type="redirect">listProduct</result>
        </action>

Find action according to the corresponding url.

 

3.Action

public String add() {
        System.out.println(product.getName());
        System.out.println(product.getCategory().getName());
        pdao.add(product);
        return "list";
}

action execute and return a String string back struts.xml

 

4.struts.xml

Centralized find the corresponding results from the results, forward or jump to the corresponding page or Action

 

5. Response Results

 

flow chart

Guess you like

Origin www.cnblogs.com/huqingfeng/p/12363685.html