attribute:
设置和Action关联的ActionForm Bean在request,session范围内的属性key.
比如你可以在这个地方设置attribute="mytest"那么如果bean在session中
你就可以直接访问
session.getAttribute("mytest");

解决方案 »

  1.   

    name的话其实也一样,不过name必须在form-bean中定义过的。
      

  2.   

    struts源码public String getAttribute() {
    //如果你没有设定attribute,那么struts 会把name的值拿过来用
    if (this.attribute == null) {
    return (this.name);
    } else {
    return (this.attribute);
    }
    }
      

  3.   

    设置和ACTION关联的ActionForm Bean 在request或 session范围内的属性Key.如:Form Bean 存在于request范围内,名字为“MyBean”,那么用
      request.getAttribut("MyBean")就可以返回它的实例。 这是孙姐在《精通STRUTS》中说的
      

  4.   

    就是把form以一个key形式放入request或session中(在配置文件的scope中指定范围,比如scope="request")然后你可以用request.getAttribute("xxxForm");或者session...来得到它
      

  5.   

    attribute指的是action对应form的key,你在页面上使用如<bean:write name="form的key" property="form属性"> ,这里form的key就是在配置文件中德attribute值,两者必须一样struts才能找到对应的form
      

  6.   

    为<action>中name属性制定的ActionForm制定一个key关键字,这样就可根据scope属性指定的范围获取该ActionForm:
    如:
    <action 
            name="userForm" 
            attribute="user"
            scope="request"
            ……
    />
    则可通过request.getAttribute("user")获取"userForm"指定的ActionForm。
    如果省略attribute属性,则可通过request.getAttribute("userForm")获取ActionForm