如何从Struts1的URL中删除".do"前缀? [英] How to remove '.do' prefix from url in Struts1?
问题描述
我已经在Struts 1框架中编写了一个Web应用程序.一切正常,但是在将用户转发到显示为actionname.do
的下一个URL时,在提交表单时一切正常.我不希望URL上有这个Struts 1默认后缀.取而代之的是,我想在URL中查看页面的名称.怎么做?
I have written a web-application in Struts 1 framework. Everything works fine but on form submission when user is forwarded to next page URL which is shown is actionname.do
. I don't want this Struts 1 default suffix on URL. Instead of it I would like to see page's name in URL. How to do it?
注意:我已经尝试在web.xml
中编辑servlet映射.已替换/*.do
.但是在那种情况下,即使我的索引页面也无法打开.
Note : I have tried editing servlet mapping in web.xml
. Have replaced /*.do
. But In that case even my index page doesn't open.
推荐答案
- 打开
/WEB-INF/web.xml
- 您将必须找到
org.apache.struts.action.ActionServlet
的servlet-name
和与servlet-name
相对应的servlet-mapping
.
- Open
/WEB-INF/web.xml
- You will have to find the
servlet-name
of theorg.apache.struts.action.ActionServlet
and theservlet-mapping
that corresponds to theservlet-name
.
例如:
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
最后,只需将url-pattern
更改为所需的内容,然后重新部署应用程序即可.
Finally, simply change the url-pattern
to what you desire and redeploy the application.
这篇关于如何从Struts1的URL中删除".do"前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!