1

In order to maintain the current set of Urls in a project, I have to be able to use the # (pound sign) in the Url. For some reason the pound sign does not appear to work normally in this project for UrlMappings.groovy.

Is there a special escape-sequence that must be used when placing # signs in UrlMappings.groovy?

Am I missing some reason why one cannot use pound signs at all?

In the following URL Mapping example, the browser goes to the correct page, but the pageName variable is null:

"/test/${urlName}#/overview"(controller:'test', action:'overview') {
    pageName = "overview"
}
jennyfofenny
  • 4,359
  • 2
  • 17
  • 15
Mark Rogers
  • 96,497
  • 18
  • 85
  • 138

2 Answers2

3

I thought everything after # in the url would be treated on the client side of the browsers where it tries to find a and scroll to that location.

If you dump the request containing the pound char, do you even see the data behind #?

netbrain
  • 9,194
  • 6
  • 42
  • 68
0

I used a Named URL mapping and it works fine, no need to escape the "#" sign:

name test: "/#abc" (controller: 'test', action:'homepage')

EDIT: My above answer is wrong. In fact, it falls to a special case when homepage is the default action of the view.

Netbrain is right, the path after "#" will never be sent to server. In stead, I found that it's possible using "%23" instead of "#". Please take a look at here.

For example, instead of /test#/abc we should use /test%23/abc as URL mapping (both at client side & server side).

Hoàng Long
  • 10,746
  • 20
  • 75
  • 124
  • It works, but additional variables in the URL Mapping are not being set for me. – jennyfofenny Apr 27 '11 at 13:49
  • @jenny: it seems the only thing we can do is replacing all "#" by "%23". – Hoàng Long Apr 28 '11 at 10:16
  • What we found out from further investigation is that anything passed after the # symbol (called the fragment identifier) is not sent to the server, it's strictly client-side: [Fragment identifier](http://en.wikipedia.org/wiki/Fragment_identifier), so it can't be captured on the server-side. – jennyfofenny Apr 28 '11 at 13:59
  • @jenny: yeah. So the answer for this question is impossible. I have read your other question: it seems you need some javascript tricks to get around. Sorry I can't help anything further – Hoàng Long Apr 28 '11 at 16:33