Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is *.do in struts-config.xml

I am learing struts and I found a mapping in Struts-config.xml as follow

<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>

in servlet mapping tag.

what is *.do

Can we achive the same in web.xml of servlets ?

Thanks in Advance ,

Raj


2 Answers

*.do - It just means that any URL that ends with a ".do"
Yes we can achive the same in web.xml of servlets

ie: any url requests that ends with .do will be redirected to the specified Servlet , In our case to the servlet named action

This Link give you a good idea about web.xml and struts-config.xml and difference between them

like image 92
Renjith K N Avatar answered Jan 30 '26 13:01

Renjith K N


As far as I know .do url invokes your servlet. I have seen this extension being used with Struts.

So if you have www.hey.com/hello.do Then you struts configuration will have something as follows

<struts-config>
    <action-mappings>
        <action path="/hello" type="com.MyAction">
    </action-mappings>
</struts-config>

So in this example the url"www.hey.com/hello.do" will be forwarded to MyAction.java

In your particular example, you found that occurrence of *.do in your web.xml file. What that means is all request that ends with *.do will be forwarded to "action" servlet.

like image 41
Susie Avatar answered Jan 30 '26 11:01

Susie