1
我有bean定义,例如弹簧,数字验证,默认值,警告消息
<bean id="DsdDetectorLogic" class="my class" init-method="init" lazy-init="true" >
<property name="threshold" value="#{ properties.threshold }" />
<property name="lag" value="#{ properties.lag }" />
...
</bean>
我需要添加特定的参数(滞后)约束,如果该参数超过了3最大值或1分钟值,我需要它得到的默认值1。此外,我需要会收到一些警告消息,表明此参数因此收到默认值。
我熟悉使用javax.validation.constraints.Min/Max的代码中字段注释的解决方案。
是否可以使用某些弹簧功能来编辑xml文件,或唯一的解决方案是在调用setter的时间内从java对象类中完成它?
纵观http://static.springsource.org/spring/docs/1.2.9/reference/beans.html我没有看到关于你问什么。但是,3.3节提到了设置构造函数的值。如果这是您的自定义类,您可能可以通过这种方式实现类似的功能。 –
@Jesse J:我找到了一种方法来部分解决我的问题,可能您可以帮助找到如何显示警告消息? (我的答案附后) – Michael