I have a class that looks like this:

public class Foobar {
   private float value;
   public void setValue(float value) {
      this.value = value;

I then have a webpage (Struts2) that passed in a variable foobar.value.

<input type="text" name="foobar.value" value="123.456">

I then get this error:

ognl.MethodFailedException: Method "setValue" failed for object Foobar@19d373d [java.lang.NoSuchMethodException: setValue([Ljava.lang.String;)]
    at ognl.OgnlRuntime.callAppropriateMethod(

I found this website that talks about creating converters

Doesn't OGNL and Struts2 have support for setting a primitive float by default?


If you change value to Float (the Object), does that work?

No, I switched it to a Float object and it didn't work. Good idea though.
Trevor Allred
Does your Action have a getter/setter for a Foobar object?

OK, I figured it out. The above code DOES work. But this does NOT work.

 <input type="text" name="foobar.value" value="-123.456">

Apparently OGNL interprets the negative number as a String. I'm not sure how to deal with this without a converter. It's nice to know that it will handle positive float and Float natively.

I did some further research on this about found this bug.

It's closed but the version 2.1.8 isn't in Maven and the latest version of Struts2 doesn't rely on it yet. :(

I think I'll be writing a converter for now.

Trevor Allred