package com.orchid.system.util; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; @Component public class SpringBeanUtil implements ApplicationContextAware { private static ApplicationContext applicationContext; @Override public void setApplicationContext(ApplicationContext ac) throws BeansException { applicationContext = ac; } public static Object getBean(String name) throws BeansException{ return applicationContext.getBean(name); } }
注意这里一点要加注解@component
然后是web.xml
<listener> <listener-class>com.orchid.system.util.SpringBeanUtil</listener-class> </listener>
然后是freemarker自定义标签的类
private ContentReleaseService contentReleaseService; public AdListDirective(){ if(contentReleaseService==null) this.contentReleaseService=(ContentReleaseService) SpringBeanUtil.getBean("contentReleaseServiceImpl"); }
new classpathxmlapplicationcontext()不知为何会报堆满了,还是这种方式获取bean很好。
还是shiro需要获取service的时候,也可以这样获取
相关推荐
NULL 博文链接:https://carolli.iteye.com/blog/1387747
NULL 博文链接:https://carolli.iteye.com/blog/1387704
NULL 博文链接:https://zhenghuazhi.iteye.com/blog/1923544
主要介绍了freemark标签的相关基础知识,基本上了解Freemark标签的应用
对freemark描述,请多多下载~~~~~~~~~~~~~~~·····
环境 freemarker 2.3.15 spring mvc 3.0.5
freemark标签使用的一些说明.希望对大家有点用。
struts2+spring2.5+hibernate3.2 + ...spring2.5 是用注释来注入 hibernate3.2 是用ejb3注解映射关系 hibernate3 +个属性可以自动生成表结构 freemarker 用摸版来表现视图,这个例子就是简单的用法没进行进一不的架设
一些很不错的freemark资料及eclipse的freemark插件
freemark开发指南详解freemark开发指南详解freemark开发指南详解freemark开发指南详解freemark开发指南详解
基础框架,可满足开发需要
Spring配置Freemarker视图解析器,配置多个视图解析器
springsecurity(用spring ibatis freemaker)实现的权限管理页面, 里头包括数据库脚本和原代码 主要参考http://blog.csdn.net/k10509806/article/details/6369131 这个人的文章做的
freemark中文资料 freemark教程 freemark基础和高级教程
freemark ,
Freemark指南:全面介绍Freemark的使用方法,让你的页面已程序完美的结合!
FREEMARK资料,开发入门指南 是开发人员了解FREEMARK的一本入门资料
springboot集成mybatis分页,freemark,spring,logback完整小例子, 可直接运行
freemark模板&模版技术&freemark模板&模版技术