- 浏览: 117048 次
- 性别:
- 来自: 成都
文章分类
最新评论
cms项目导入myeclipse
1.在myeclipse中新建一个项目jeecms,将服务器中jeecms项目下web-inf文件夹下内容拷到新建项目中
2.解压缩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下的web.xml复制出来覆盖掉新建项目WEB-INF下的web.xml
5.classes下有四个文件,手动烤到myeclipse项目src根目录下中
6.将服务器上jeecms项目删掉,发布新建的jeecms项目。
首页的加载过程:
在浏览器中输入http://localhost:8080/jeecms,回车
首先进入配置文件web.xml,
应用范围内的初始化参数
其中jeecms-context.xml是对标签的初始化
通过以上标签找到应该加载哪一个页面
通过servlet配置,可以找到jeecms-servlet-front.xml,在此配置文件的最后有
<import resource="jeecms-servlet-front-action.xml"/>代码
找到jeecms-servlet-front-action.xml,在此配置文件中有
<bean id="dynamicAct" class="com.jeecms.cms.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为例
首先,每一个标签的声明都是在jeecms-context.xml中进行的,
此外,在配置文件jeecms-servlet-front.xml中,还有一段对标签的配置
</bean>类ContentListDirective继承自AbstractContentDirective,最主要的是execute方法
Content_list.html中的内容
就是简单的将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三个字段
其次,创建了一个实体类
接下来是配置hibernate中jc_mycontent表的配置文件
与数据库交互的持久层接口
标签类的抽象类,最主要的就是getData这个方法,以及绑定业务层,其中可以添加多种查询方法。可参考类AbstractContentDirective
//没有采用默认的模板,直接采用自己写的简单的模板(mycontent_list.html)
FrontUtils.includeTpl(TPL_NAME, site, params, env);
样式模板mycontent_list.html内容,里边可以自己添加一些样式,可参考\t\cms_sys_defined\style_list下样式文件
首页里加入如下代码
通过以上这些代码,可以实现将自己的表jc_mycontent中的数据查询并显示在页面上
1.在myeclipse中新建一个项目jeecms,将服务器中jeecms项目下web-inf文件夹下内容拷到新建项目中
2.解压缩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下的web.xml复制出来覆盖掉新建项目WEB-INF下的web.xml
5.classes下有四个文件,手动烤到myeclipse项目src根目录下中
6.将服务器上jeecms项目删掉,发布新建的jeecms项目。
首页的加载过程:
在浏览器中输入http://localhost:8080/jeecms,回车
首先进入配置文件web.xml,
<context-param> <param-name>contextConfigLocation</param-name> <!----> <param-value> /WEB-INF/config/application-context.xml /WEB-INF/config/cache-context.xml /WEB-INF/config/captcha-context.xml /WEB-INF/config/jeecore-context.xml /WEB-INF/config/jeecms-context.xml </param-value> </context-param>
应用范围内的初始化参数
其中jeecms-context.xml是对标签的初始化
<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/config/jeecms-servlet-front.xml</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配置,可以找到jeecms-servlet-front.xml,在此配置文件的最后有
<import resource="jeecms-servlet-front-action.xml"/>代码
找到jeecms-servlet-front-action.xml,在此配置文件中有
<bean id="dynamicAct" class="com.jeecms.cms.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为例
首先,每一个标签的声明都是在jeecms-context.xml中进行的,
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" default-lazy-init="true"> …… <bean id="cms_content_list" class="com.jeecms.cms.action.directive.ContentListDirective"/>(声明标签对应的类) <bean id="staticPageSvc" class="com.jeecms.cms.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>
此外,在配置文件jeecms-servlet-front.xml中,还有一段对标签的配置
<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 = FrontUtils.getSite(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 = DirectiveUtils.getInvokeType(params); //获取传入参数,列表样式,根据不同的参数获取不同的样式列表 String listStyle = DirectiveUtils.getString(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) { body.render(env.getOut()); } else { throw new RuntimeException("invoke type not handled: " + type); } //将variable中的params值移除 DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); } @SuppressWarnings("unchecked") protected List<Content> getList(Map<String, TemplateModel> params, Environment env) throws TemplateException { Integer[] ids = DirectiveUtils.getIntArray(PARAM_IDS, params); if (ids != null) { //根据内容ID数组获取文章列表 return contentMng.getListByIdsForTag(ids, getOrderBy(params)); } else { return (List<Content>) super.getData(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" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.jeecms.cms.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 = Finder.create(); 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 myContentDao.getList(); } private MyContentDao myContentDao; @Autowired//自动绑定 public void setMyContentDao(MyContentDao myContentDao) { this.myContentDao = 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 myContentMng.getList(); } @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 = FrontUtils.getSite(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值移除 DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); } protected List<MyContent> getList(Map<String, TemplateModel> params, Environment env) throws TemplateException { return myContentMng.getList(); } }
样式模板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中的数据查询并显示在页面上
发表评论
-
JAVA中SELECT COUNT(*) FROM XXX得到的ResultSet行数
2013-06-05 16:37 1067/** * 测试SELECT COUNT(* ... -
My Eclipse 编辑jsp页面卡机
2013-04-24 18:21 1309困惑很久的问题今天终于解决了。。 我想大家都遇到编辑JSP页 ... -
简易WordPress模板代码帮助手册中文版
2013-03-27 22:30 926WordPress模板基本文件 style.css 样式表 ... -
MyEclipse 9.0 安装freemarker编辑器
2012-12-12 18:08 783freemarker几天前才发布了2.3.17版本,5月21号 ... -
XYTipsWindow插件弹出层之关闭
2012-12-12 10:20 5195XYTipsWindow插件弹出层之关闭 加载一个网页到框架 ... -
让html select支持readonly属性
2012-12-06 11:20 834刚刚碰到一个要为html select添加readonly属性 ... -
兼容各个数据库的sql语句 Criteria
2012-12-05 08:22 1319Session session = HibernateUtil ... -
freemarker处理小数和整数共存的情况
2012-12-04 17:06 3208前几天在写程序的时候,利用的freemarker做的表示层。程 ... -
Freemarker中输出数字特别是Long型数字时格式带逗号问题
2012-12-03 10:08 1321Long i=100000000l; Map model ... -
数据库表与表连接的方式(内连接、外连接[左连接、右连接、全连接]、交叉连接)
2012-11-20 22:15 1156第一部分、查询理论 连接查询方式有: 内连接、外连接(左连 ... -
FreeMarker 基础知识 表达式(引用)
2012-11-20 21:24 828表达式是FreeMarker的核心功能,FreeMarker中 ... -
2011-07-07 00:10 mysql 自增id 归0
2012-11-20 21:10 752最近老是要为现在这个项目初始化数据,搞的很头疼,而且数据库的I ... -
hibernate Restrictions 用法 查询
2012-11-20 20:57 668import hibernate classes impor ... -
hibernate Restrictions 用法 查询
2012-11-20 20:54 0import hibernate classes imp ... -
解决MyEclipse内存不足
2012-07-09 08:48 707做项目的时候,MyEclipse提示内存不足,我本本内存2G的 ... -
在Dreamweaver中tpa,tppabs标签批量清除
2012-04-19 22:55 1336匹配tppabs标签: \btppabs="h[ ... -
java 365*1000*60*60*24 计算问题
2012-04-12 18:59 880long y = 365*1000*60*60*24; Sy ... -
Java获取操作系统信息
2011-09-21 18:11 717import java.util.Properties; ... -
添加/修改Eclipse中HTML、JSP等模板
2011-07-07 16:41 1420先找到myeclipse模板配置文件 %myeclipse- ... -
制作浏览器地址栏&收藏夹里的小图标
2011-05-28 18:12 749如果您使用的 WEB 浏览器是 IE5 或以上版本,那么当您将 ...
相关推荐
齐博cms开发文档,所有文档资料。大家来看看那!
包括模板和标签语法的入门教程,帝国CMS二次开发的帮助文档,帝国CMS二次开发资源地址收集
Interwoven的旗舰产品Teamsite 6.7.1版本开发文档说明书
EmpireCMS开发文档 帝国cms,EmpireCMS,EmpireCMS开发文档,帝国cms开发文档
CMS需求文档.zip程序开发文档软件开发文技术档下载CMS需求文档.zip程序开发文档软件开发文技术档下载CMS需求文档.zip程序开发文档软件开发文技术档下载CMS需求文档.zip程序开发文档软件开发文技术档下载 1.合个人...
铭飞CMS是集简单、健壮、灵活、开源几大特点的开源内容管理系统,是国内开源java-CMS的领先品牌,基于,目前程序安装量已达七十万,超过六成的站点正在使用织梦CMS.的标签模式而开发。
飞飞CMS系统程序文件 飞飞CMS又名飞飞PHP影视系统,包括有PHP版(ppvod)与ASP版(adncms),飞飞CMS由飞飞老谭独立开发,免费提供给站长使用,最大亮点是一键采集海量影视资源!
08CMS房产系统里面一个全景插件,可以实现全景看房功能,这个大家应该有了解,在手机旁就可以实现360度全景看房体验,另外我们还有火车头房源采集工具插件,第三方,还有适合08CMS的链家模板插件,安装使用遇到问题找Q:...
08cms房产网汽车网商业破解版,PHP 5.2.3或更高版本才能运行此版本的08CMS
本教程主要是对08CMS后台的相关信息进行了详细的讲解,以方便大家更容易的使用08CMS。
本插件系针对五指cms开发的短信插件,插件内的所有文件均为对原文件的修改,如果你的系统经过二次开发,安装本插件之前,请仔细核对修改。
74CMS骑士模版开发手册3.2版—离线版HTML版,现在共享给大家,欢迎使用。
RuoYi开发手册(离线版)
深喉咙企业建站系统V4.11标签说明文档
通过图文结合的方式详细的为大家介绍了08CMS后台是如何管理操作的。
We7 CMS.NET源码+详细中文文档We7 CMS.NET源码+详细中文文档We7 CMS.NET源码+详细中文文档We7 CMS.NET源码+详细中文文档We7 CMS.NET源码+详细中文文档We7 CMS.NET源码+详细中文文档We7 CMS.NET源码+详细中文...
74cms二次开发文档,74 smarty自定义函数,模板使用方法
携云CMS(XerCMS)基于php mysql编写的内容管理系统,集成会员、社区,留言本,新闻及模型管理等功能,为个人/企业建站提供最佳选择。 XerCMS 20151029 更新日志: 增加会员中心退出链接后台美化 特点: 高效...
pigcms二次开发文档,东西齐全
开源 免费 java CMS FreeCMS 二次开发文档