Announcement Announcement Module
Collapse
No announcement yet.
Simple question of SPeL in xml files Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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]@{}

    Comment


    • #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):
      Code:
      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:
      Code:
      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:
      Code:
      value="\'This #{expression} *should* be evaluated and surrounding single quotes kept\'"
      Last edited by ttimbul; Mar 28th, 2010, 11:33 AM. Reason: exploring simpler solutions

      Comment


      • #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:
        Code:
        value="This backslash escaped \#{expression} *should not* be evaluated"
        and:
        Code:
        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.

        Comment


        • #5
          Filed JIRA improvement request http://jira.springframework.org/browse/SPR-7041

          Comment

          Working...
          X