Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-2732

<s:text name="key"/> OGNL-evaluates "key" when it is not found in resource bundle

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.1.2
    • 2.1.3
    • Plugin - Tags, Value Stack
    • None
    • Tested with 2.1.2, but the issue could have existed earlier.

    Description

      <s:text name="key"/> outputs the resource message designated by "key".

      If no such message exists (and the body of the tag is empty), it reverts to outputting the name of the key itself, as an unevaluated string. At least, that's the behaviour of the tag, as described in the documentation.

      In fact, however, the name of the key is now being evaluated as an OGNL expression, and if that turns out to be valid, that is what's printed.

      This, in my view, is counter-intuitive and probably counter-productive. Consider the case of a ModelDriven<Book> action exposing a Book-object to the View.
      Normally,

      <s:text name="title"/>: ${title}

      would have yielded:

      title: The Great Gatsby

      if the resource message "title" was missing from the resource bundle. That's not too bad an outcome. However, with the key being OGNL-evaluated, we would get the following output:

      The Great Gatsby: The Great Gatsby

      which I find a little puzzling...

      Attachments

        Activity

          People

            Unassigned Unassigned
            pierdeux Pierre Thibaudeau
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: