Search code examples
javastruts2ognl

How to disable ognl evaluation?


To force OGNL evaluation one could use the %{} syntax, but what should be used to disable it?

Consider following code -

<s:a action="likeButton">
   <s:param name="returnAction" value="viewItem" />
</s:a>

What happens is that viewItem is looked up on the value stack and when it isn't found an empty string gets returned.

likeButton?returnAction=

This is not what I want. What I wanted was the literal value viewItem to be passed as a parameter.

likeButton?returnAction=viewItem

Solution

  • You should delimiter your literal with single quotes inside the double quotes and then it should be fine.

    <s:a action="likeButton">    
        <s:param name="returnAction" value="'viewItem'" /> 
    </s:a> 
    

    Regards,