Spring mvc 显示';对象';而不是SpringMVC的参数值+;使用MessageSource实现i18n
使用SpringMVC,将显示“对象”名称而不是参数值。下面是我的代码Spring mvc 显示';对象';而不是SpringMVC的参数值+;使用MessageSource实现i18n,spring-mvc,internationalization,Spring Mvc,Internationalization,使用SpringMVC,将显示“对象”名称而不是参数值。下面是我的代码 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,
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);
}
输出:
应为:键“参数”处于非活动状态。
Actual:key'[Ljava.lang.Object;@394a861'处于非活动状态
有人能告诉我应该做些什么来获得预期的输出吗。试试这个:
return messageSource.getMessage(msgKey, params, Locale.US);