OpenCMS integration with Spring MVC--reference
ref from:http://blogs.indrajitpingale.com/?p=8
http://blog.shinetech.com/2013/04/09/integrating-springmvc-with-opencms/
It is assumed that you have successfully deploted OpenCMS 8.x on either Tomcat or JBoss (How to deploy OpenCMS on JBoss?). Also, it is assumed that your are hands-on on Spring MVC.
So there are 6 part of Spring MVC application.
- classes (Controllers and other)
- JSP files
- Assets (image, js, css and other files)
- Spring taglibs (spring-form.tld, spring.tld) *** if any ***
- Servlet configuration files (xxxx-servlet.xml)
- libs (your application might need more or less)
- aopalliance-1.0.jar
- ehcache-1.2.3.jar
- hibernate-3.2.3.ga.jar
- log4j-1.2.17.jar
- opencmsspring_c3p0-0.9.1-pre5a.jar
- opencmsspring_hibernate3.2.jar
- rapid-web.jar
- spring-aop-3.0.5.RELEASE.jar
- spring-asm-3.0.5.RELEASE.jar
- spring-beans-3.0.5.RELEASE.jar
- spring-context-3.0.5.RELEASE.jar
- spring-context-support-3.0.5.RELEASE.jar
- spring-core-3.0.5.RELEASE.jar
- spring-expression-3.0.5.RELEASE.jar
- spring-jdbc-3.0.5.RELEASE.jar
- spring-orm-3.2.3.RELEASE.jar
- spring-tx-3.0.5.RELEASE.jar
- spring-web-3.0.5.RELEASE.jar
- spring-webmvc-3.0.5.RELEASE.jar
- web.xml
Steps to deploy Spring MVC application in openCMS.
- Copy all libs to “opencms.war\WEB-INF\lib” folder.
- Copy *.tld, xxxx-servlet.xml, xxxx-service.xml to “opencms.war\WEB-INF” folder.
- Create .jar of your classes (only classes nothing else) and copy it to “opencms.war\WEB-INF\lib” folder.
- Now the tricky part is web.xml, don’t copy it to ”opencms.war\WEB-INF” otherwise it will overwrite openCMS’s web.xml. Follow the following steps.
- Open openCMS’s web.xml (opencms.war\WEB-INF\web.xml) for edit.
- 1st copy following
<!-- Begin: OpenCmsSpring Integration -->
<
context-param
>
<
param-name
>contextConfigLocation</
param-name
>
<
param-value
>/WEB-INF/OpenCmsSpring-service.xml</
param-value
>
</
context-param
>
<
filter
>
<
filter-name
>CharacterEncoding</
filter-name
>
<
filter-class
>
org.springframework.web.filter.CharacterEncodingFilter
</
filter-class
>
<
init-param
>
<
param-name
>encoding</
param-name
>
<
param-value
>UTF-8</
param-value
>
</
init-param
>
<
init-param
>
<
param-name
>forceEncoding</
param-name
>
<
param-value
>true</
param-value
>
</
init-param
>
</
filter
>
<!-- End: OpenCmsSpring Integration -->
under following
<
context-param
>
<
param-name
>DefaultWebApplication</
param-name
>
<
param-value
>ROOT</
param-value
>
</
context-param
>
- 2nd copy following
<!-- Begin: OpenCmsSpring Integration -->
<
listener
>
<
listener-class
>org.springframework.web.context.ContextLoaderListener</
listener-class
>
</
listener
>
<
servlet
>
<
servlet-name
>OpenCmsSpring</
servlet-name
>
<
servlet-class
>org.springframework.web.servlet.DispatcherServlet</
servlet-class
>
<
load-on-startup
>1</
load-on-startup
>
</
servlet
>
<!-- End: OpenCmsSpring Integration -->
under following
<
listener
>
<
listener-class
>org.opencms.main.OpenCmsListener</
listener-class
>
</
listener
>
- 3rd copy following to redirect spring request to RewriteFilter.
<!-- Begin: OpenCmsSpring Integration -->
<
servlet-mapping
>
<
servlet-name
>OpenCmsSpring</
servlet-name
>
<
url-pattern
>*.htm</
url-pattern
>
</
servlet-mapping
>
<
filter
>
<
filter-name
>RewriteFilter</
filter-name
>
<
filter-class
>com.ipingale.filter.RewriteFilter</
filter-class
>
</
filter
>
<
filter-mapping
>
<
filter-name
>RewriteFilter</
filter-name
>
<
url-pattern
>/*</
url-pattern
>
</
filter-mapping
>
<
filter-mapping
>
<
filter-name
>CharacterEncoding</
filter-name
>
<
url-pattern
>/*</
url-pattern
>
</
filter-mapping
>
<!-- End: OpenCmsSpring Integration -->
under following
<
servlet-mapping
>
<
servlet-name
>OpenCmsWebDavServlet</
servlet-name
>
<
url-pattern
>/webdav/*</
url-pattern
>
</
servlet-mapping
>
- 4th and last copy following to add support to spring Taglibs
<!-- Begin: Spring Integration -->
<
taglib
>
<
taglib-uri
>/spring</
taglib-uri
>
<
taglib-location
>/WEB-INF/spring.tld</
taglib-location
>
</
taglib
>
<
taglib
>
<
taglib-uri
>/form</
taglib-uri
>
<
taglib-location
>/WEB-INF/spring-form.tld</
taglib-location
>
</
taglib
>
<!-- End: Spring Integration -->
under following
<
taglib
>
<
taglib-location
>/WEB-INF/opencms.tld</
taglib-location
>
</
taglib
>
- Now start Tomcat/JBoss.
- Open openCMS dashboard (http://localhost:8080/opencms/opencms/system/login/).
- Create any site (folder) inside site/default for e.g. “demo1″.
- Upload all JSP files under this folder (site/default/demo1).
- Now about Assets. Where to put those in openCMS?
- For that create Module from Administrator view (with name “com.ipingale.demo.module”).
- Add resource folder to that module.
- Copy all Assets under that folder.
- Touch ups.
- Assets links, e.g. css, js, images, etc. referred in JSP. You need to modify them as follows.
Before:<
link
href
=
"css/style.css"
rel
=
"stylesheet"
type
=
"text/css"
/>
After:
<
link
href="<cms:link>/system/modules/com.ipingale.demo.module/resources/css/style.css</
cms:link
>" rel="stylesheet" type="text/css" />
- To support “” you need to add following on the top of each JSP page.
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
- Rename all .jsp files to .spg (or anything other than known mime types).
- Assets links, e.g. css, js, images, etc. referred in JSP. You need to modify them as follows.
That’s it you are ready now.
Click on your start page (index.spg) and here you go.
You can download working example from below location.
This entry was posted in OpenCMS, Spring-MVC on February 4, 2014.
OpenCMS integration with Spring MVC--reference的更多相关文章
- Spring Security(三十六):12. Spring MVC Test Integration
Spring Security provides comprehensive integration with Spring MVC Test Spring Security提供与Spring MVC ...
- 使用MockMvc测试Spring mvc Controller
概述 对模块进行集成测试时,希望能够通过输入URL对Controller进行测试,如果通过启动服务器,建立http client进行测试,这样会使得测试变得很麻烦,比如,启动速度慢,测试验证不方便 ...
- Spring MVC Hello World Example(转)
Spring 3 You may interest at this Spring 3 MVC hello world example. In Spring MVC web application, i ...
- Spring MVC Integration,Spring Security
http://docs.spring.io/spring-security/site/docs/4.2.0.RELEASE/reference/htmlsingle/#authorize-reque ...
- Spring MVC Hibernate MySQL Integration(集成) CRUD Example Tutorial【摘】
Spring MVC Hibernate MySQL Integration(集成) CRUD Example Tutorial We learned how to integrate Spring ...
- 玩转单元测试之Testing Spring MVC Controllers
玩转单元测试之 Testing Spring MVC Controllers 转载注明出处:http://www.cnblogs.com/wade-xu/p/4311657.html The Spri ...
- spring mvc 介绍
Spring MVC Tutorial tag. * * If you do not want to deal with the intricities of the noscript * secti ...
- Spring mvc 4系列教程(一)
一.Spring框架概览 Spring框架是一种轻量级.一站式解决企业级应用的解决方案.不仅如此,Spring的模块化的特点,可以使你只引用所需要的部分,而无需引用全部.你可以使用控制反转容器(IoC ...
- Spring Boot Reference Guide
Spring Boot Reference Guide Authors Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch, ...
随机推荐
- [转] 在Asp.net前台和后台弹出提示框
一.在前台弹出提示框 1.点击"A"标记或者"控件按钮"弹出提示框 <asp:LinkButton ID="lbtnDel" runa ...
- FOR 循环 索引从n 开始
RF 中FOR 循环默认是从0开始,如果想从任意n开始如下所示: 方法一: 结果,如你所愿输出1-6: 方法二,利用FOR遍历list来实现: 结果: 这里注意是输出1-9而不是1-10
- 房租管理小软件(七):flowlayoutPancel 中增加分类控
见下图的 string FNodeName = dt.Rows[i]["FNodeName"].ToString(); ) { RoomControl.Thumbnail.Grou ...
- 欢迎来到Googny的博客
本博客主要分享笔者的学习知识,以及工程中遇到的技术问题. 由于笔者技术水平有限,博客不足之处在所难免,还请各位网友不吝交流,共同进步. 一起体会分享的乐趣. JavaScript 部分 该部分深入浅出 ...
- Java学习笔记(1)
封装基本原则之一: 将实例变量标记为private,将getters与setters标记为public,用setters来检查参数并判断是否可以执行: 局部变量与实例变量的区别: 你无需初始实例变量, ...
- 题目1043:Day of Week(输入日期与当前日起天数差%7,在做相关星期调整)
题目描述: We now use the Gregorian style of dating in Russia. The leap years are years with number divis ...
- MVC5中使用KinEditor
参考:http://www.cnblogs.com/weicong/archive/2012/03/31/2427608.html 第一步 将 KindEditor 的源文件添加到项目中,建议放到 / ...
- 基于野火M3开发板(STM32F103VET6)的迷宫小球(重力感应控制)游戏开发
2013-03-03 这是研一上学期<实时嵌入式系统实验>课程的大作业,是利用野火板的资源,加上一个AHRS(Attitude and Heading Reference System,姿 ...
- 浅析Netty的异步事件驱动(一)
本篇文章着重于浅析一下Netty的事件处理流程,Netty版本为netty-3.6.6.Final. Netty定义了非常丰富的事件类型,代表了网络交互的各个阶段.并且当各个阶段发生时,触发相应的事件 ...
- 50道经典的JAVA编程题 (11-15)
50道经典的JAVA编程题 (11-15),新年的第一天,继续啦...\(^o^)/~,这50道题都跨年了啊...哈哈 [程序11] TestTN.java 题目:有1.2.3.4个数字,能组成多少个 ...