目前我需要Spring bean的JSP 2.0标签使用此代码:如何将spring bean注入到jsp 2.0 SimpleTag中?
ac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
ac.getBeansOfType(MyRequestedClass.class);
的我只是得到第一个匹配的bean。
此代码工作正常,但不想要的缺点,我花了大约一半我的网页渲染时间查找春豆,因为这发生的每一个标签调用时。我在想也许把bean放到应用程序范围或至少会话范围内。但是,处理这个问题最聪明的方法是什么?
“[http://stackoverflow.com/questions/3445908/is-there-一个优雅的方式注入一个弹簧管理的bean到一个java自定义简单] [1]'有一个很好的答案。 [1]:http://stackoverflow.com/questions/3445908/is-there-an-elegant-way-to-inject-a-spring-managed-bean-into-a-java- custom-simpl – Angus 2012-03-02 20:01:48