Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

form:options tag should display string instead of int  RSS feed

albert kao
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to use the form:options provided by Spring to provide as choices in string instead of int.
e.g. display "Monthly", "Block" and "Per Use" as choices but save the choice in billingType as int.

My JSP implemented with Spring 2.5.6 is
[code] <td><form:select path="billingType">
<form:options items="${addAccountCommand.billingTypeChoice}"/>

(Note. The following is not implemented because running it in Eclipse will cause an Exception in thread "main" org.mozilla.javascript.EvaluatorException: syntax error (addAccount.jsp#17)
at org.mozilla.javascript.DefaultErrorReporter.runtim eError(
at org.mozilla.javascript.DefaultErrorReporter.error(
<td><form:select path="billingType">
<form:options items="${addAccountCommand.billingTypeChoice}" itemValue="billingType" itemLabel="billingTypeName" />
end Note)

My is
[code] private int billingType;
private String billingTypeName;

public int getBillingType() {
return billingType;

public void setBillingType(final int billingType) {
this.billingType = billingType;

public String getBillingTypeName() {
return billingTypeName;

public void setBillingTypeName(final String billingTypeName) {
this.billingTypeName = billingTypeName;

public Map<String, Integer> billingTypeChoice = new HashMap<String, Integer>() {
put("Monthly", 1);
put("Block", 2);
put("Per Use", 3);

public Map<String, Integer> getBillingTypeChoice() {
return billingTypeChoice;

public void setBillingTypeChoice(final Map<String, Integer> billingTypeChoice) {
this.billingTypeChoice = billingTypeChoice;

My jsp page apppears with "1", "2" and "3" as options instead of "Monthly", "Block" and "Per Use".
Clicking the "Add" button cannot submit the form.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!