gpt4 book ai didi

java-ee-6 - 如何更改 Bean Validation 中 ValidationMessages.properties 的位置

转载 作者:行者123 更新时间:2023-12-02 19:14:05 25 4
gpt4 key购买 nike

默认情况下,ValidationMessages.properties 可以位于我的类路径的根目录中。我可以更改此文件的位置(例如 com.myapp.Anything.properties)吗?

最佳答案

来自 JSR-303 规范:

4.3.1.1. Default message interpolation algorithm The default message interpolator uses the following steps:

  1. Message parameters are extracted from the message string and used as keys to search the ResourceBundle named ValidationMessages (often materialized as the property file /ValidationMessages.properties and its locale variations) using the defined locale (see below). If a property is found, the message parameter is re- placed with the property value in the message string. Step 1 is applied recursively until no replacement is per- formed (i.e. a message parameter value can itself contain a message parameter).

看来这是默认的和建议的。为了支持这一点,JSR-303 TCK 使用 TestNG 将它们移动到“WEB-INF/classes/”目录,该目录与资源类路径上的“./”相同。

(你可以尝试一下,但这就是我所能弄清楚的。)

抱歉。

关于java-ee-6 - 如何更改 Bean Validation 中 ValidationMessages.properties 的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6293157/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com