Displaying 'Object' instead of parameter value for SpringMVC + i18n by using MessageSource

StackOverflow https://stackoverflow.com/questions/22681674

  •  22-06-2023
  •  | 
  •  

Frage

With SpringMVC, 'Object' name is displaying instead of parameter value. Below is my code.

msg("label.key.is.inactive", "Parameter");

label.key.is.inactive = key ''{0}'' is inactive. -- Present in properties file

@Autowired
private MessageSource messageSource;

protected String msg(final String msgKey,final Object... params){
  return messageSource.getMessage(msgKey, new Object[]{params}, Locale.US);
}

Output: Expected: key 'Parameter' is inactive. Actual: key '[Ljava.lang.Object;@394a861' is inactive.

Can someone tell me what should be done to get the expected output.

War es hilfreich?

Lösung

Try this:

return messageSource.getMessage(msgKey, params, Locale.US);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top