jeecms初体验D2-freemarker篇

  本文是拿jeecms2.4.2这一版本来介绍struts2和freemarker之间的整合以及jeecms的二次开发(由于是基于jeecms这一系统,可能公司开发人员对一些代码有所改动)

 回顾:

  struts2的工作流程:

  1. 请求

  2. 核心控制器FilterDispatcher将分析请求,通过struts.xml配置文件访问哪个Action

  3. 在访问Action之前请求会经过 拦截器(Intercepter)自动对请求进行拦截(比如说:验证、url分析实现权限控制、防止恶意攻击等等)

  4. 执行Action中的方法(默认是execute)

  5. 根据struts.xml配置文件返回到指定的视图资源。

 jeecms配置分析:

  框架最先加载struts.xml 随后按照配置文件中的配置依次对文件进行加载,其中struts-default.xml是定义了一些struts2中核心的bean和拦截器栈。这些个拦截器是以key-value的形式存在,name指的是拦截器的名字,value是拦截器实现类。

  另外在看对bean的配置时

<bean class="org.apache.struts2.views.freemarker.FreemarkerManager" name="struts" />

<bean type="org.apache.struts2.components.template.TemplateEngine" name="ftl" class="org.apache.struts2.components.template.FreemarkerTemplateEngine" />

 

就是对struts和freemarker的整合,然后再对整个站action结果集的配置

<result-types>
<result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
<result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult"/>
<result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult" default="true"/>
<result-type name="httpheader" class="org.apache.struts2.dispatcher.HttpHeaderResult"/>
<result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/>
<result-type name="redirectAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>
<result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/>
<result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
<result-type name="plainText" class="org.apache.struts2.dispatcher.PlainTextResult" />
<!--自定义result-type-->
<result-type name="json" class="com.googlecode.jsonplugin.JSONResult">
<param name="root">jsonRoot</param>
</result-type>    
<result-type name="pageCache" class="com.fcms.cms.web.PageCacheResult" />
</result-types>

 

 

转载于:https://www.cnblogs.com/xmaomao/archive/2013/04/07/3003677.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值