• jeecms初体验D2freemarker篇


      本文是拿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>
  • 相关阅读:
    Entity Framework 和NHibernate的区别
    Windows 2008 的TCP/IP原理
    Mono 2.0正式发布了
    自定义Unity对象生命周期管理集成ADO.NET Entity Framework
    Entity Framework(EF)数据查询
    WCF采用 netTcpBinding 发生的Socket errors
    ADO.NET 实体框架概述
    IronPython 2.0 beta 5
    用sp_change_users_login消除Sql Server的孤立用户
    微软修改了Managed Extensibility Framework(MEF)的协议
  • 原文地址:https://www.cnblogs.com/xmaomao/p/3003677.html
Copyright © 2020-2023  润新知