Using a dash in Struts 2 action name

2019-08-10 09:53发布

I have the following action:

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

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

2条回答
Emotional °昔
2楼-- · 2019-08-10 10:14

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

your Struts application will see:

http://domain.name/namespace/

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.

See also these links:

查看更多
对你真心纯属浪费
3楼-- · 2019-08-10 10:16

The special character # is not allowed as a part of the action name. If you want to build url using the action name, you can use url tag.

<s:url var="url" action="" anchor="dash_creds"/>
查看更多
登录 后发表回答