一  Jeecms安装过程
将解压后得到的jeecms-3.0.2-final文件夹下的root文件夹更名为jeecms拷贝到tomcat 安装目录下的webapps 文件夹下(例如: D:\Tomcat 6.0\webapps\),启动tomcat,在地址栏中输入localhost:8080/jeecms, 您将看到第一步安装过程中的《用户许可协议》,勾选“我已经阅读并同意此 协议”,点击下一步, 接下来第二步安装过程中设置系统参数,系统会自动检测出一些配置项,请根据您的实际情 况填写,数据库密码不能为空。 点击提交后进入第三步进入最后的系统安装过程,安装过程可能需要十几秒的等待时间。安 装成功后将提示信息,请再重启Tomcat 完成安装。 
Tomcat重启完毕之后,在浏览器的地址栏中输入localhost:8080/jeecms, 
若系统正常显示默认的站点首页则表示JEECMS 已经顺利安装完成.
附:                                 
     系统管理后台登录:localhost:8080/jeecms/jeeadmin/jeecms/index.do
     用户名:admin 
     密 码:password 
图文安装步骤如下:
将解压后得到的ROOT文件夹拷贝到tomcat安装目录下的webapps文件夹下(例如:D:\Tomcat 6.0\webapps\),启动tomcat,在地址栏中输入localhost:8080,您将看到第一步安装过程中的《用户许可协议》,如图一所示,勾选“我已经阅读并同意此协议”,点击下一步,
 
图一:用户许可协议
接下来第二步安装过程中设置系统参数,系统会自动检测出一些配置项,请根据您的实际情况填写,如图二所示,数据库密码不能为空。
 
图二:系统参数设置
点击提交后进入第三步进入最后的系统安装过程,安装过程可能需要十几秒的等待时间。安装成功后将提示如图三所示的页面信息,请再重启Tomcat完成安装。
 
图三:系统安装完成
三、完成安装
    Tomcat重启完毕之后,在浏览器的地址栏中输入localhost:8080,若系统正常显示默认的站点首页则表示JEECMS已经顺利安装完成.,如图四所示:
 
图四 站点首页
二  Jeecms项目导入myeclipse
1.在myeclipse中新建一个项目jeecms,将服务器中jeecms项目下web-inf文件夹下内容拷到新建项目中
解压缩jeecms-3.0.2-final-src,在src文件夹下会看到有三个压缩文件,如果只想进行普通的二次开发,可以只导入cms这个源码,删除jeecms-cms-identity-3.0.2-final.jar即可,如果想进行深入的二次开发,需要导入common和core源码,另导入common-lib下的jar包,删除jeecms-cms- identity-3.0.2-final.jar,jeecms-common-3.0.2-final.jar ,jeecms-core- identity-3.0.2-final.jar这三个jar包,切记:务必进行build path
3.修改jdbc链接,自己导入数据库。 
4.把服务器下install\config下的l复制出来覆盖掉新建项目WEB-INF下的l
5.classes下有四个文件,手动烤到myeclipse项目src根目录下中
6.将服务器上jeecms项目删掉,发布新建的jeecms项目。
三  首页的加载过程
在浏览器中输入localhost:8080/jeecms,回车
首先进入配置文件l,
<context-param>
<param-name>contextConfigLocation</param-name>

<param-value>
/WEB-INF/l
/WEB-INF/l
/WEB-INF/l
/WEB-INF/l
/WEB-INF/l
</param-value>
</context-param>

应用范围内的初始化参数
其中l是对标签的初始化

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.shtml</welcome-file>
<welcome-file>index.jhtml</welcome-file>
</welcome-file-list>
通过以上标签到应该加载哪一个页面

<servlet>
<servlet-name>JeeCmsFront</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/l</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JeeCmsFront</servlet-name>
<url-pattern>*.jhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>JeeCmsFront</servlet-name>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>JeeCmsFront</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>JeeCmsFront</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

通过servlet配置,可以到l,在此配置文件的最后有
<import resource="l"/>代码
到l,在此配置文件中有
<bean id="dynamicAct" class="s.action.front.DynamicPageAct"/>
可以到类DynamicPageAct,此类是首页模板。
在类DynamicPageAct中有
public static final String TPL_INDEX = "tpl.index";
到WEB-INF\languages\jeecms_front下messages_zh_CN.properties配置文件,可以到对应的首页面
tpl.index=首页(工程中的首页.html文件)



四  标签的配置流程
以cms_content_list为例首先,每一个标签的声明都是在l中进行的,
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="/schema/beans" xmlns:xsi="/2001/XMLSchema-instance"
xsi:schemaLocation="/schema/beans /schema/beans/spring-beans-3.0.xsd"
default-lazy-init="true">
……
<bean id="cms_content_list" class="s.action.directive.ContentListDirective"/>(声明标签对应的类)
<bean id="staticPageSvc" class="s.staticpage.StaticPageSvcImpl">
<property name="freeMarkerConfigurer">
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="freemarkerVariables">
<map>
……
<entry key="cms_content_list" value-ref="cms_content_list"/>
……
</map>
</property>
<property name="templateLoaderPath" value=""/>
……
</bean>
</property>
</bean>
</beans>
此外,在配置文件l中,还有一段对标签的配置
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="freemarkerVariables">
<map>
……
<entry key="cms_content_list" value-ref="cms_content_list"/>
……
  </map>
</property>
         ……
</bean>

</bean>类ContentListDirective继承自AbstractContentDirective,最主要的是execute方法
public class ContentListDirective extends AbstractContentDirective {
/**
 * 模板名称
 */
public static final String TPL_NAME = "content_list";

/**
 * 输入参数,文章ID。允许多个文章ID,用","分开。排斥其他所有筛选参数。
 */
public static final String PARAM_IDS = "ids";

@SuppressWarnings("unchecked")
public void execute(Environment env, Map params, TemplateModel[] loopVars,
TemplateDirectiveBody body) throws TemplateException, IOException {
//获取站点
CmsSite site =&Site(env);
//获取内容列表,可以通过此处进行更改,获取自己数据库中的数据
List<Content> list = getList(params, env);

Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(
params);
//OUT_LIST值为tag_list,在类DirectiveUtils中声明,将内容列表放入其中
paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list));
//将params的值复制到variable中
Map<String, TemplateModel> origMap = DirectiveUtils
.addParamsToVariable(env, paramWrap);
//获取的是参数PARAM_TPL,是否调用模板以及调用的模板类型
InvokeType type =&InvokeType(params); springframework jar包导入
//获取传入参数,列表样式,根据不同的参数获取不同的样式列表
String listStyle =&String(PARAM_STYLE_LIST, params);
if (InvokeType.sysDefined == type) {
if (StringUtils.isBlank(listStyle)) {
throw new ParamsRequiredException(PARAM_STYLE_LIST);
}
//列表样式模板
env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true);
} else if (InvokeType.userDefined == type) {
if (StringUtils.isBlank(listStyle)) {
throw new ParamsRequiredException(PARAM_STYLE_LIST);
}
//列表样式模板路径 WEB-INF\t\cms_sys_defined\style_list\style_2-1.html
FrontUtils.includeTpl(TPL_STYLE_LIST, site, env);
} else if (InvokeType.custom == type) {
//这个模板就是自己声明的,即content_list.html,如果采用自定义模板的话,页面中可以只写上标签,并添加上标签内需要的几个参数,不需要写标签体的内容,会去自动调用模板中的标签体。
FrontUtils.includeTpl(TPL_NAME, site, params, env);
} else if (InvokeType.body == type) {
Out());
} else {
throw new RuntimeException("invoke type not handled: " + type);
}
//将variable中的params值移除
veParamsFromVariable(env, paramWrap, origMap);
}

@SuppressWarnings("unchecked")
protected List<Content> getList(Map<String, TemplateModel> params,
Environment env) throws TemplateException {
Integer[] ids =&IntArray(PARAM_IDS, params);
if (ids != null) {
//根据内容ID数组获取文章列表
return&ListByIdsForTag(ids, getOrderBy(params));
} else {
return (List<Content>)&Data(params, env);
}
}

@Override
protected boolean isPage() {
return false;
}
}

Content_list.html中的内容
[#list tag_list as a]
<li><a href="${a.url}" target="_blank">${a.title}</a></li>
[/#list]
就是简单的将tag_list中的内容,即“paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list));”中放入的数据遍历出来

style_2-1.html中的内容 主要是对图文列表或标题列表向上滚动的样式的,其中包含两个同样为样式的文件
style_2-1_core.html(图文列表或标题列表向上滚动)和style_1-1_core.html(图文列表或标题列表向上滚动),在此就不做赘述了。

Jeecms是基于Spring注解,在自定义标签时对于实体类和dao service等注意注解的问题。

五  自定义标签及使用自己创建的表的实现过程
下面是我自己定义的标签mycontent_list
首先,在数据库里创建了一个jc_mycontent的表,其中有id,title,content三个字段
其次,创建了一个实体类
public class MyContent {
private static final long serialVersionUID = 1L;
private Integer id;
private String title;
private String content;
public MyContent () {
super();
}
……get set方法
}
接下来是配置hibernate中jc_mycontent表的配置文件
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "hibernate.sourceforge/hibernate-
mapping-3.0.dtd">
<hibernate-mapping package="s.entity.main">
<class name="MyContent" table="jc_mycontent">
<meta attribute="sync-DAO">false</meta>
<cache usage="read-write"/>
<id name="id" type="java.lang.Integer" column="id"><generator class="identity"/></id>
<property name="title" column="title" type="java.lang.String" not-null="true" />
<property name="content" column="content" type="java.lang.String" not-null="true" />
</class>
</hibernate-mapping>

与数据库交互的持久层接口
public interface MyContentDao {
public List<MyContent> getList();
}
持久层实现类
@Repository//持久层
public class MyContentDaoImpl extends HibernateBaseDao<MyContent, Integer>
implements MyContentDao {
@SuppressWarnings("unchecked")
public List<MyContent> getList(){
return find(byNothing());
}
private Finder byNothing(){
Finder f =&ate();
f.append("from MyContent");//可以在此处添加查询条件或者添加各种方法进行动态查询
f.setCacheable(true);
return f;
}

@Override
protected Class<MyContent> getEntityClass() {
return MyContent.class;
}
}
业务层接口
public interface MyContentMng {
public List<MyContent> getList();
}
业务层实现类
@Service//业务层
@Transactional
public class MyContentMngImpl implements MyContentMng {

@Transactional(readOnly = true)//配置事务为只读
public List<MyContent> getList(){
return&List();
}
private MyContentDao myContentDao;
@Autowired//自动绑定
public void setMyContentDao(MyContentDao myContentDao) {
ContentDao = myContentDao;
}
private List<ContentListener> listenerList;
@Autowired
public void setListenerList(List<ContentListener> listenerList) {
this.listenerList = listenerList;
}
}
标签类的抽象类,最主要的就是getData这个方法,以及绑定业务层,其中可以添加多种查
询方法。可参考类AbstractContentDirective
public abstract class AbstractMyContentDirective implements
TemplateDirectiveModel {
protected Object getData(Map<String, TemplateModel> params, Environment env)
throws TemplateException {
return&List();
}
@Autowired
protected MyContentMng myContentMng;
}
自定义标签中最重要的类继承上边的抽象类
public class MyContentListDirective extends AbstractMyContentDirective {
/**
 * 模板名称
 */
public static final String TPL_NAME = "mycontent_list";
@SuppressWarnings("unchecked")
public void execute(Environment env, Map params, TemplateModel[] loopVars,
TemplateDirectiveBody body) throws TemplateException, IOException {
//获取站点
CmsSite site =&Site(env);
//获取内容列表
List<MyContent> list = getList(params, env);
Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>(params);
//OUT_LIST值为tag_list,将内容列表放入其中
paramWrap.put(MYOUT_LIST, DEFAULT_WRAPPER.wrap(list));
//将params的值复制到variable中
Map<String, TemplateModel> origMap = DirectiveUtils.addParamsToVariable(env, paramWrap);
//没有采用默认的模板,直接采用自己写的简单的模板(mycontent_list.html)
FrontUtils.includeTpl(TPL_NAME, site, params, env);
//将variable中的params值移除
veParamsFromVariable(env, paramWrap, origMap);
}
protected List<MyContent> getList(Map<String, TemplateModel> params,
Environment env) throws TemplateException {
return&List();
}
}
样式模板mycontent_list.html内容,里边可以自己添加一些样式,可参考\t\cms_sys_defined\style_list下样式文件
[#list mytag_list as a]
<li><a href="${a.title}"><font color='blue'>"${a.content}"</font></a></li>
[/#list]

首页里加入如下代码
[@cms_mycontent_list]
  <ul class="topnews">
  </ul>
[/@cms_mycontent_list]
通过以上这些代码,可以实现将自己的表jc_mycontent中的数据查询并显示在页面上
标签使用和模板的制作
1模板规划
1.1资源文件
资源文件就是网页中用到的图片、CSS、JS等元素,在CMS系统中所有的资源文件在网站的根目录中的
/res_base/所属网站定义资源目录/TEMPLEATE/WEB
/res_base/所属网站定义资源目录/TEMPLEATE/WAP
解释:网站定义资源
在CMS系统中可以同时管理多个网站,也就是多个网站可以同时使用一套CMS系统,但是每一个网站都已属于自己独立的资源文件及模板文件目录。
1.2模板文件
定义了页面显示的主体框架,它的位置位于网站根目录下的/WEB_INF/user_base/所属网站模板目录;
模板规则:
1、以index前缀命名的为首页模板
2、以channel前缀命名的为栏目模板
3、以content前缀命名的为内容模板
4、以alone前缀命名的为栏目单页模板
1.3使用方式
1、使用dw建立站点
2、将网页中用到的资源文件分类分别放置到网站相关资源目录中
3、将模板文件放置按照命名规则分别放置到网站相关模板目录中。
4、将头部、底部等等具有通用元素的模板文件放置到模板目录中的include目录中
5、将模板文件中所有资源引用改为绝对路径链接至资源目录中
6、在栏目管理中将模板文件与栏目进行关联设置
7、在模板文件中需要提取数据的位置放置相应的标签
1.4标签调用样式
调用"JEECMS标签"的三种代码样式如下:
  A、${标签名称}
  B、[@cms.标签名称 属性='值'/]
  C、[@cms.标签名称 属性='值'; 标签别名] 自定义样式模板 [/@cms.标签名称]
  例如:
a、${web.name}标签用于调用网站名称
b、[@cms.ArtiList chnlId='' count='10' sysContent='1-1' /]标签用于调用10篇文章的列表
C、[@cms.ChnlList id='' inner='1';c]|<a href=="${c.url}">>${c.name}</a> [/@cms.ChnlList]标签用于调用栏目列表,可用于网站导航条。
  注意:abc实例是与上面ABC三种形式相对应的。大家可以逐个测试,举一反三

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。