Struts1.2 中配置文件中的Action的attribute属性起什么作用 - shangpeijie's blog - 博客频道 - youkuaiyun.com
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
--
服务器上采用的是struts.
owner.jsp中有个form(表单),点击submit后该表单被提交到服务器。
而owner.jsp中,设置该表单的响应者是owner.do
owner.do被服务器执行后生成的页面被返回到用户的IE中
所以地址栏里的地址为 http://localhost:8080/easyStruts/owner.do;jsessionid=D3DE9D20146718E5BF45CEA878A2A951
-
*.do 是在web.xml中设置,这是struts的约定,你当然可以不用.do了,不过你 用.do别人容易理解阿,因为所有人都是这样用的.具体流程是这样的:
在jsp form中action="owner.do"->web.xml->*.do 映射到ActionServlet->struts-config.xml-><action path="/owner"->找到对应的action class和form-bean....
-
首先,<html:form action="/owner">是提交到ActionServlet的,这个在web.xml中是有固定配置的,就是<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>,对应的url是<url-pattern>*.do</url-pattern>。
然后,这个ActionServlet到struts-config.xml中根据"/owner",找到对应的所要跳转到的ActionBean(或者jsp页面)以及所要使用的FormBean(封装页面数据)。