在Struts 2动作名称中使用破折号 [英] Using a dash in Struts 2 action name

查看:59
本文介绍了在Struts 2动作名称中使用破折号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将执行以下操作:

<action name="#dash_creds" class="AccountDashboardActionBean">
    <result name="success" type="stream">
        <param name="contentType">application/json</param>
        <param name="inputName">jsonInputStream</param>
    </result>
</action>

我希望Struts在我的URL中接受#符号或忽略它,因为它现在不调用我的操作.

I want Struts to accept the # symbol in my URL or to ignore it, for now it does not call my action.

推荐答案

哈希符号用于标识URL的片段"部分;网址中第一个#之后的所有内容均被视为片段的一部分,并且不会发送给服务器.

The hash symbol is used to identify the "fragment" part of the URL; everything after the first # in a url is treated as part of the fragment and it is not sent to the server.

这意味着将永远不会到达其中带有#的动作名称;如果您是从浏览器中调用的话:

This means that an action name with a # in it will never be reached; if you call this from the browser:

http://domain.name/namespace/#dash_creds

您的Struts应用程序将看到:

your Struts application will see:

http://domain.name/namespace/

出于同样的原因,我认为没有办法让Struts忽略它".您的操作名称不应包含哈希.

For the same reason, I don't think there's a way to make Struts "ignore it". Your action name should not include an hash.

另请参阅以下链接:

  • http://en.wikipedia.org/wiki/Fragment_identifier
  • https://blog.httpwatch.com/2011/03/01/6-things-you-should-know-about-fragment-urls/

这篇关于在Struts 2动作名称中使用破折号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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