简体   繁体   English

java属性文件中的花括号是什么意思?

[英]What do curly braces inside a java property file mean?

We have many property files inside our java project. 我们的java项目中有很多属性文件。 I don't understand the meaning of the integer values inside the curly braces. 我不明白花括号内的整数值的含义。
Example: 例:
validation.error=Input Validation Failed for field:[{0}]. validation.error =字段输入验证失败:[{0}]。 Reason:[{1}] 原因:[{1}]

They are for use with the MessageFormat class . 它们用于MessageFormat Something of the form {n} , where n is a number, is a placeholder for a dynamic value. {n}形式的某些形式,其中n是数字,是动态值的占位符。

There are additional things you can add to the placeholder for formatting purposes; 您还可以添加其他内容以添加到占位符以进行格式化; see the linked Javadocs above for more information. 有关更多信息,请参阅上面链接的Javadoc。

They're placeholders for parameters. 它们是参数的占位符。 When used, two parameters would be passed to indicate the name of the field and the reason for failure. 使用时,将传递两个参数以指示字段的名称和失败的原因。

The curly brackets are placeholders. 大括号是占位符。

You can use placeholders in your messages and replace them with location-appropriate values at runtime based on the semantics of your user's language. 您可以在消息中使用占位符,并在运行时根据用户语言的语义将其替换为适合位置的值。 For this you use the MessageFormat class. 为此,您使用MessageFormat类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM