【发布时间】:2014-10-30 08:36:02
【问题描述】:
我有一个自定义标签。当我注入spring消息资源并想要访问属性文件时,注入的bean始终为null。 我做错了什么,
@Component
public class GridColumnsCutomTagHander extends TagSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
@Inject
private MessageSource messageSource;
private String propertyFileName;
/**
* @return the propertyFileName
*/
public String getPropertyFileName() {
return this.propertyFileName;
}
/**
* @param propertyFileName
* the propertyFileName to set
*/
public void setPropertyFileName(String propertyFileName) {
this.propertyFileName = propertyFileName;
}
@Override
public int doStartTag() throws JspException {
try {
JspWriter out = pageContext.getOut();
String gridColumnValues = messageSource.getMessage(propertyFileName,
null, EWMSUser.getCurrentLanguageLocale());
out.println(gridColumnValues );
} catch (IOException e) {
e.printStackTrace();
}
return (SKIP_BODY);
}
请帮助我找出问题所在
【问题讨论】:
-
什么是消息源?类或接口。你能显示 Spring 的 XML 配置吗
标签: spring-mvc inject