Using a dash in Struts 2 action name

500 views Asked by At

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

There are 2 answers

0
Roman C On

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"/>
0
dipanda On

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: