当用户为 Double 值插入错误输入时,我想显示一条自定义消息,但是当我测试我的应用程序时,我总是看到默认错误消息。
那是我的自定义messages.properties:
`javax.faces.convert.DoubleConverter.CONVERSION=My Conversion Error(Double)
javax.faces.convert.DoubleConverter.CONVERSION_detail=My Conversion Error(Double)
javax.faces.component.UIInput.CONVERSION=My Conversion Error
javax.faces.component.UIInput.CONVERSION_detail=My Conversion Error(Double)
javax.faces.validator.NOT_IN_RANGE=My Validation Error
javax.faces.validator.NOT_IN_RANGE_detail=My Validation Error
javax.faces.validator.DoubleRangeValidator.LIMIT=Validation Limit Double
javax.faces.validator.DoubleRangeValidator.LIMIT_detail=Validation Limit Double
javax.faces.validator.DoubleRangeValidator.TYPE=Error Type Double
javax.faces.validator.DoubleRangeValidator.TYPE_detail = Error Type Double
javax.faces.component.UIInput.REQUIRED=Requested!!
`
在这里我的 faces.config
`<application>
<message-bundle>it.exaple.messages.MyMsg</message-bundle>
</application>`
这是我的页面:
`<td>
<h:inputText id="Value" value="#{user.value}" required="true">
<f:validateDoubleRange minimum="0.0" maximum="200.0"/></h:inputText>
<h:message for="username" showDetail="true" showSummary="true" style="color:red"/>
</td>`
这真的很奇怪,因为当我使用空值测试我的应用程序时,我可以读取我的自定义消息,但是当我尝试插入一个字符串时,我看到了默认错误消息!当我将 a 设置为过高或过低的值时,也会发生同样的事情!
任何人都可以帮助我吗?谢谢!