1

for example

    <global-forwards>
      <forward name="welcome"  path="/Welcome.do"/>
    </global-forwards>

    <action-mappings>
      <action path="/Welcome" forward="/welcomeStruts.jsp"/>
    </action-mappings>

My question is: When client requests Welcome.do page, the global forward will map the /welcome.do page with the name attribute "welcome". Then in action-mapping it will map between the name in forward tag with the path in action tag so it will know that it should forward to the welcomeStruts.jsp file.
Am I correct?
If not, how can it determine the correct mapping between user's request *.do to the corresponding jsp file?
Thank you

Xitrum
  • 7,765
  • 26
  • 90
  • 126

1 Answers1

2

You're not correct. When a request comes in, Struts tries to map the URL or the request with the path of an action. Forwards are not used at this stage.

When the action returns a forward name, Struts first looks for a forward with this name in the forwards of the action, and if not found, it looks in the global forwards.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • just 1 more thing, i dont understand how the requests will be mapped with the corresponding action controlles, i tried finding the mapping in web.xml and struts-config.xml but i didn't see that part. Can you explain it ? Thank you – Xitrum Feb 20 '12 at 10:05
  • 1
    Usually, the web.xml has a mapping for the URL pattern `*.do` to the Struts servlet. Then the Struts servlet removes .do from the path of the request, and finds the action that has the resulting path. – JB Nizet Feb 20 '12 at 10:23
  • so do you mean that it will happend at this part of the struts-config.xml file : – Xitrum Feb 20 '12 at 10:25
  • 2
    I mean that is the request path is /AddSelCommand.do, Struts will execute this action, because its path is /AddSelCommand. – JB Nizet Feb 20 '12 at 10:33