4

I'm using Spring 3.1.0 JARs for my application. I have mapped my bean class with view through command name, I have no problem with mapping it works clearly.

The issue is that I'm having an int variable in my bean class:

private int id;

When I map this variable with <'form:input path="id" />', it gives the default value 0 in the text box which I don't want there. How can I get rid of this?

Constantino Tsarouhas
  • 6,846
  • 6
  • 43
  • 54
sree
  • 535
  • 4
  • 12
  • 26

1 Answers1

11

I assume you are referring to a form model with 'id' as the private attribute to the model. Have you tried using an Integer instead of an int. An Integer is the class version of the primitive type int and this may solve your problem.

blackpanther
  • 10,998
  • 11
  • 48
  • 78
  • Yes, that's probably the only way. `int` can't hold an "empty" value, so you need a type which can. `String`, with you converting later, would be the other option. – dbreaux Feb 28 '13 at 14:46
  • @blackpanther Hey thanks blackpanther its nice to get quick and exact answer for what I'm looking for... Thanks a lot its working you have saved my time... – sree Feb 28 '13 at 14:52
  • @blackpanther Due to insufficient reputation I'm not able to vote for your answer... Really sorry... – sree Feb 28 '13 at 14:53