“.action”的解释Struts2 URL中的扩展意义 [英] Explanation of ".action" extention significance in Struts2 URL

查看:223
本文介绍了“.action”的解释Struts2 URL中的扩展意义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个无用或蹩脚的问题,但请解释一下。

This might be a useless or lame question but please explain me this.

在struts2中,当我们为表单按钮分配操作并单击该按钮时,将调用该操作。现在,当显示操作文件的结果时,浏览器中的URL显示

In struts2 when we assign an action to a form button and click on that button, that action is called. Now, when the result of the action file is displayed, the URL in browser shows

localhost:8080/HelloWorld/ClassName.action

有时默认 .action part doesn'显示。但两者都是一样的。

Sometimes by default .action part doesn't show. But both works the same.

我需要向某人解释这个 .action 的重要性。为什么扩展名显示在URL中,是否有一些特定的东西可以启用和禁用Struts2 URL中的 .action

I am required to explain to someone what is significance of this .action. Why is that extension shown in URL and is there some specific thing which enables and disables the .action in Struts2 URL?

推荐答案

如果使用默认操作映射器从请求URL获取映射,则它使用操作扩展来确定操作名称部分。可以使用 struts.xml (或 struts.properties

If the default action mapper is used to get the mapping from the request url it uses the action extension to determine the action name part. The action extension could be configured with the constant in struts.xml (or struts.properties)

<constant name="struts.action.extension" value="action,,"/> 

是默认值。在某些情况下,如果您需要访问静态资源而不是在同一路径下执行操作,则可以使用.action扩展来区分操作与静态资源。如果您没有或不使用这些资源,那么您可以通过从上面的配置中删除 action 来轻松禁止它。

that is default. In some cases if you need to access the static resources instead of action under the same path you could use the ".action" extension to distinguish action from the static resource. If you don't have or don't use such resources then you could easily suppress it by removing action from the configuration above.

这篇关于“.action”的解释Struts2 URL中的扩展意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆