Announcement Announcement Module
No announcement yet.
Simple question of SPeL in xml files Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple question of SPeL in xml files

    I have the need to escape the #{} because I have ognl in a string value that keeps on triggering the SPeL which causes errors. Any help would be great.

  • #2
    found a work around for the time being. I can specify the map implementation in ognl and avoid the expression language from trying to evaluate it.

    #@[email protected]{}


    • #3
      I find this annoying too, I think ideally it should be possible to escape expressions by prefixing with a backslash or by surrounding the entire value with quotes.

      After toying around I've found the following, unfortunately rather inconvenient, workaround to work just fine (defining the value as a SpEL String):
      value="#{'This #{expression} is not evaluated'}"
      It would be nice to have an easier way of doing this, e.g. surround the entire value with single quotes as I mentioned above:
      value="'This #{expression} *should not* be evaluated and surrounding single quotes dropped'"
      Surely someone will come up with a situation where you'd want to keep the single quotes as part of the output and evaluating the expression, in which case they should probably be escaped like so:
      value="\'This #{expression} *should* be evaluated and surrounding single quotes kept\'"
      Last edited by ttimbul; Mar 28th, 2010, 10:33 AM. Reason: exploring simpler solutions


      • #4
        Thinking about it, it will probably be better to use a simple backslash escape so that individual #{} or ${} expressions can be prevented from being evaluated.

        So above example would become:
        value="This backslash escaped \#{expression} *should not* be evaluated"
        value="'Escaped: \#{expression} and any quotes are not affected'"
        This would allow a pick and match approach (expressions can be selectively escaped) and avoids confusion about single quotes.


        • #5
          Filed JIRA improvement request