java struts-config.xml 中的 *.do 是什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12297420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 08:20:58  来源:igfitidea点击:

what is *.do in struts-config.xml

javaservletsstruts

提问by Susie

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

我正在学习 struts,我在 Struts-config.xml 中找到了一个映射如下

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

in servlet mapping tag.

在 servlet 映射标记中。

what is *.do

什么是 *.do

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

我们可以在 servlet 的 web.xml 中实现相同的目标吗?

Thanks in Advance ,

提前致谢 ,

Raj

拉吉

回答by Renjith K N

*.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 .dowill be redirected to the specified Servlet , In our case to the servlet named action

*.do- 这只是意味着任何以“.do”结尾的 URL
是的,我们可以在 servlet 的 web.xml 中实现相同的目标,

即:任何.doaction

This Linkgive you a good idea about web.xmland struts-config.xmland differencebetween them

这个链接让你对web.xmlstruts-config.xml以及它们之间的区别有一个很好的了解

回答by Susie

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

据我所知 .do url 调用您的 servlet。我已经看到这个扩展与 Struts 一起使用。

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

所以如果你有 www.hey.com/hello.do 那么你的struts配置会有如下内容

<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

所以在这个例子中 url"www.hey.com/hello.do" 将被转发到 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.

在您的特定示例中,您发现在 web.xml 文件中出现了 *.do。这意味着所有以 *.do 结尾的请求都将被转发到“action”servlet。

回答by Dipul Patel

Every url which ends with *.do it calls your servlet.

每个以 *.do 结尾的 url 都会调用你的 servlet。