1、在一般情况下,actionForm是被存储在一定的scope中(request或session,通过action的scope属性来配置),当我们在配置时,指定name而不指定attribute,那么指定的name值就作为actionForm存储在scope中的key值,我们可以在action中通过httpServletRequest.getAttribute("指定的name属性值")来获得这个actionForm; 当我们既配置了name又配置了attribute,那么actionForm存储在scope中的key值就采用attribute属性指定的值了,这时要通过httpServletRequest.getAttribute("指定的attribute属性值")来获得actionForm,此时通过httpServletRequest.getAttribute("指定的name属性值")是不能获得actionForm的。 所以,是否配置attribute属性就决定了actionForm存储在scope中的key值是采用name,还是采用attribute public String getAttribute() { //如果你没有设定attribute,那么struts 会把name的值拿过来用 if (this.attribute == null) { return (this.name); } else { return (this.attribute); } } 为中name属性制定的ActionForm制定一个key关键字,这样就可根据scope属性指定的范围获取该ActionForm: 如: 则可通过request.getAttribute("user")获取"userForm"指定的ActionForm。 如果省略attribute属性,则可通过request.getAttribute("userForm")获取ActionForm 设置和ACTION关联的ActionForm Bean 在request或 session范围内的属性Key.如:Form Bean 存在于request范围内,名字为“MyBean”,那么用 request.getAttribut("MyBean")就可以返回它的实例。 这是孙姐在《精通STRUTS》中说的 就是把form以一个key形式放入request或session中(在配置文件的scope中指定范围,比如scope="request") 然后你可以用request.getAttribute("xxxForm");或者session...来得到它