struts1.x基本action的配置与使用

    技术2026-05-13  9

    struts1.x基本action的配置与使用

     

    <!--

    struts1.x的action配置都很简单,

    继承自Action的自定义Action配置如下,

    当要进生输入校验时必设置validate为true,

    input 指定验证出错后要返回的页面

     -->

            <action path="/register" type="edu.yzu.action.UserAction"

                input="/register.jsp" validate="true" name="userForm">

                <forward name="success" path="/result.jsp"></forward>

            </action>

    <!--

    继承自MappingDispatcherAction,多了一个parameter属性,

    此属性指定本此请求调用此action中的哪个方法。

     -->

            <action path="/updateorder" type="edu.yzu.action.OrderAction"

                 parameter="updateOrder">

                <forward name="success" path="/result.jsp"></forward>

            </action>

    <!--

    继承自DispatcherAction跟继承自MappingDispatcherAction配置相同,不过

    parameter的含义不同,它后面指定的值要在请求此action的url后面加上,如一个删除订单的请求应该为

    http://localhost/shopcart/deleteorder.do?method=deleteOrder  其中method后面的值为要调用action

    的方法名。

     

     -->   

            <action path="/deleteorder" type="edu.yzu.action.OrderAction"

                 parameter="method">

                <forward name="success" path="/result.jsp"></forward>

            </action>

     

            <!--

            LookupDispatcherAction与DispatcherAction的配置相同,但是含义不同

            它的parameter指的是页面按提交按钮的name值。并且按键的value必须要有资源文件的支持,且在其action中

            指定这个值与action内的方法的对应关系。很麻烦,由此可见这个LookupDispatcherAction实在不常用!

             -->

            <action path="/usermanage" type="edu.yzu.action.UserLookupAction" parameter="callmethod">

            <forward name="success" path="/ok.jsp"></forward>

            </action>

    最新回复(0)