Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about null value in struts 2

 
asif rafique
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone

i am using struts 2 in my project every thing is fine .
when i submit a form struts setter injection call setter of all bean properties and set there values, any text field that is left bland by user on submit it is initialize by empty string What i want a null instead of empty string
any help to submit a null value instead of String will be appreciated
thanks in advance
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Asif this is the correct behavior. When the request doesn't contain a request parameter, then the value of a parameter is null. If the request parameter exists, and has no value, then it is equivalent to an empty string. I think to avoid this, you must use the requiredstring-validator or implement your own parameter interceptor but the former would be the correct way of doing this...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic