Struts 2 ParametersInterceptor

Are your logs being filled up with errors like:

ERROR - ParametersInterceptor.setParameters(204) | ParametersInterceptor - [setParameters]: Unexpected Exception caught setting '_' on 'class Error setting expression '_' with value '[Ljava.lang.String;@1491ddc'

If so, it's because Struts 2 is parsing the query string/post data and trying to "set" a value for each parameter it finds.

I'm working on an Struts 2 application utilizing the jQuery JavaScript library for the UI and the Displaytag tag library for displaying tables.

With jQuery, I'm using the "no-cache" option (cache: false) on all Ajax calls, which adds "_=timestamp" to each request. Since I don't have a property called "_" in my Action class, I get an error (mentioned above) in my logs for each request.

Same with Displaytag, except the parameters causing errors are in the form of "d-#-X", where "#" is a unique id (usually 4 or 5 digits) and "X" is either p, s or o. They are used to determine the page (p) and/or the table sort order (o for asc/desc and s for which column).

The solution: configure Struts (struts.xml) to ignore these parameters:

   <interceptor-stack name="defaultStack">
      <interceptor-ref name="params">
            Excludes the jQuery no-cache _ parameter and
            the Displaytag d-#-X parameter(s)
         <param name="excludeParams">

If you have a different parameters that are causing problems, just put them in the excludeParams node, comma separating multiple parameters.


  1. July 25, 2008 @ 11:15 am #

    Thanks. Very useful.

  2. September 19, 2008 @ 5:12 pm #

    prototype.js (v1602) appends an additional request parameter ('&_=') for certain browsers. To suppress via code, implement ParameterAware like so:

    public void setParameters(Map parameters) {
      // prototype.js appends a request parameter '_=' 
      if (parameters.get("_") != null) {
  3. September 19, 2008 @ 8:39 pm #

    @s2-newB - Thanks for the suggestion. Since that is the same parameter that jQuery uses, wouldn't the excludeParams example that I gave do the same thing?

  4. October 27, 2008 @ 2:47 pm #

    Thanks, man! That really helped me out!

  5. September 3, 2009 @ 3:11 am #

    Thanks eric ,
    After long search i got here .... you are a champ
    Keep up the good work

Leave a Comment

Sorry, comments are closed. You can contact me directly, if you like.

Eric Martin