0

For some reason I get this in Struts2:

Unexpected Exception caught setting 'submit' on 'class ru.user.action.IndexAction: Error setting expression 'submit' with value ['Submit', ]

The only place where 'Submit' is figuring is next piece of code:

<s:form action="index" style="margin-top:8px">
    <s:checkboxlist label="Select one or more answers" list="colors" name="yourColor" value="defaultColor" />
    <s:submit value="Submit" name="submit" style="float:left"/>
</s:form>

What is the reason for this behavior?

andy007
  • 907
  • 1
  • 15
  • 41

2 Answers2

0

I changed one line to:

<s:submit value="Submit" style="float:left"/> 

and there is no error.

andy007
  • 907
  • 1
  • 15
  • 41
0

As someone has already said, its because submit button is with 'name' property set and the Action has no setter method for it. So removing the 'name' property prevents that message, btw its not needed on a submit button.

And if someone, to support i18n, is using the property 'key' on struts <s:submit>, which auto generates the properties 'name' and 'value' on the html tag, one can set 'name' empty so struts will override the auto generated property.

<s:submit key="someresourcebundlekey" name="">

Luís Alves
  • 81
  • 2
  • 4