我ReloadableResourceBundleMessageSource
在我的 web 项目中使用,我将类注入到 servlet,问题是我想使用 Spring 注释注入类,但它似乎不起作用?我的代码是:
我的.xml
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:myList</value>
</list>
</property>
<property name="cacheSeconds" value="1"/>
</bean>
myServletClass.java
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("my.xml");
String message = applicationContext.getMessage(message, null, "Default
", null);
}
如何注入ReloadableResourceBundleMessageSource
using 注释?