Spring - set a property only if the value is not null

前端 未结 6 1687
星月不相逢
星月不相逢 2020-12-14 01:28

When using Spring, is it possible to set a property only if the value passed is not null?

Example:


          


        
6条回答
  •  -上瘾入骨i
    2020-12-14 02:04

    For solve your problem, you have to use SEL(Spring Expression Language). By this feature (added in SPring 3.0) you can such as other dynamic language writing your condition. For your context, answer is:

    
       
    
    

    for more information see(this tutorial says what use SEL in context file): http://static.springsource.org/spring/docs/3.0.5.RELEASE/reference/expressions.html

提交回复
热议问题