したがって、これは単に、SpringとJavaでさまざまなメッセージ解決/補間がどのように行われるかについての私自身の理解の欠如によるものであると確信しています。
InternationalMessages.properties
BadParsingFormat={{0}} should fall betweeen {1} and {2}
pointTop=The top coordinate
pointLeft=The left coordinate
APIEndPoint.java
// Standard implementation and wiring of message source
@Autowired
MessageSource messageSource;
public void someMethod(String somethingToParse) {
String parsed;
try {
parsed = SomeKindOfParser.parse(somethingToParse);
}
catch(BadParsingFormatException exception) {
String error = messageSource.getMessage("BadParsingFormat",
new Object[]{
exception.getVariableName(),
exception.getLowerBound(),
exception.getUpperBound()
});
// Do something useful with this error message
}
}
は、またはこの安っぽい例のexception.getVariableName()
いずれかを返します。それらをさらに特定の名前に分解/補間したいのですが、それをうまくやってのけることができないようです。別のmessageSource呼び出しを使用して、そのバンドル値を個別に取得できることはわかっていますが、それを回避できるのであれば、それをお勧めします。pointTop
pointLeft