首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

struts2学习札记-action的method属性

2012-09-02 
struts2学习笔记-action的method属性关键字: struts2 action method属性这篇文章主要是对struts2学习笔记

struts2学习笔记-action的method属性
关键字: struts2 action method属性
这篇文章主要是对"struts2学习笔记-Action的配置及基础应用和原理"文章中关于Action方法部分的补充和使用详解,大家在阅读这篇文章时请注意和理解红色粗体字样部分

Action的method属性配置主要用于将Action类中的每一个处理方法都定义成一个逻辑Action方法,如下面的xml配置片断:

Xml代码 
<!DOCTYPE struts PUBLIC 
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
        "http://struts.apache.org/dtds/struts-2.0.dtd"> 
<struts> 
    <package name="systemManage" extends="struts-default" namespace="/system"> 
        <action name="userLogin" method="login"> 
            <result name="success">/success.jsp</result> 
            <result name="error">/error.jsp</result> 
        </action> 
         
        <action name="userRegist" method="regist"> 
            <result name="success">/success.jsp</result> 
            <result name="error">/error.jsp</result> 
        </action> 
    </package> 
</struts> 

以上配置代码把LoginAction中的login和regist方法都配置成逻辑Action。要调用login方法,则相应的把index.jsp中表单元素的action设置为"system/userLogin.action";要调用regist方法,把regist.jsp中表单元素的action设置为"manage/userRegist.action"。

热点排行