File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes url-mapping in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "url-mapping in Struts" Watch "url-mapping in Struts" New topic

url-mapping in Struts

Vrushali Gore
Ranch Hand

Joined: Oct 17, 2005
Posts: 40
Hi all

Can anyone help me in knowing what exectly we do when we specify url-pattern as *.do? What that do indiactes? Does it mean that struts framework gives .do extension by default to every page?

Thanks in advance.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you look in your web.xml file, you will find an entry similar to the following:

This is essentially telling the server: "If you get a request URL that ends in .do, pass it to the Struts ActionServlet class for processing".
Once inside ActionServlet, the code knows that if the URL is /, it is to instantiate and call execute on the class you've defined for the "/myAction" mapping.

Going the other direction, if you specify "/myAction" as the action in an html:form tag, the tag logic will append ".do" to the action when it is composing the actual URL that gets sent to the server when the form it submitted.

Consultant, Sima Solutions
I agree. Here's the link:
subject: url-mapping in Struts
It's not a secret anymore!