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.

  1. classes (Controllers and other)
  2. JSP files
  3. Assets (image, js, css and other files)
  4. Spring taglibs (spring-form.tld, spring.tld) *** if any ***
  5. Servlet configuration files (xxxx-servlet.xml)
  6. libs (your application might need more or less)
    1. aopalliance-1.0.jar
    2. ehcache-1.2.3.jar
    3. hibernate-3.2.3.ga.jar
    4. log4j-1.2.17.jar
    5. opencmsspring_c3p0-0.9.1-pre5a.jar
    6. opencmsspring_hibernate3.2.jar
    7. rapid-web.jar
    8. spring-aop-3.0.5.RELEASE.jar
    9. spring-asm-3.0.5.RELEASE.jar
    10. spring-beans-3.0.5.RELEASE.jar
    11. spring-context-3.0.5.RELEASE.jar
    12. spring-context-support-3.0.5.RELEASE.jar
    13. spring-core-3.0.5.RELEASE.jar
    14. spring-expression-3.0.5.RELEASE.jar
    15. spring-jdbc-3.0.5.RELEASE.jar
    16. spring-orm-3.2.3.RELEASE.jar
    17. spring-tx-3.0.5.RELEASE.jar
    18. spring-web-3.0.5.RELEASE.jar
    19. spring-webmvc-3.0.5.RELEASE.jar
  7. web.xml

Steps to deploy Spring MVC application in openCMS.

 
  1. Copy all libs to “opencms.war\WEB-INF\lib” folder.
  2. Copy *.tld, xxxx-servlet.xml, xxxx-service.xml to “opencms.war\WEB-INF” folder.
  3. Create .jar of your classes (only classes nothing else) and copy it to “opencms.war\WEB-INF\lib” folder.
  4. 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.
    1. Open openCMS’s web.xml (opencms.war\WEB-INF\web.xml) for edit.
    2. 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>
    3. 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>
    4. 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>
    5. 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-uri>http://www.opencms.org/taglib/cms</taglib-uri
          <taglib-location>/WEB-INF/opencms.tld</taglib-location
      </taglib>
  5. Now start Tomcat/JBoss.
  6. Open openCMS dashboard (http://localhost:8080/opencms/opencms/system/login/).
  7. Create any site (folder) inside site/default for e.g. “demo1″.
  8. Upload all JSP files under this folder (site/default/demo1).
  9. Now about Assets. Where to put those in openCMS?
    1. For that create Module from Administrator view (with name “com.ipingale.demo.module”).
    2. Add resource folder to that module.
    3. Copy all Assets under that folder.
  10. Touch ups.
    1. 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" />
    2. To support “” you need to add following on the top of each JSP page.
      <%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
    3. Rename all .jsp files to .spg (or anything other than known mime types).

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 OpenCMSSpring-MVC on February 4, 2014.

OpenCMS integration with Spring MVC--reference的更多相关文章

  1. Spring Security(三十六):12. Spring MVC Test Integration

    Spring Security provides comprehensive integration with Spring MVC Test Spring Security提供与Spring MVC ...

  2. 使用MockMvc测试Spring mvc Controller

    概述   对模块进行集成测试时,希望能够通过输入URL对Controller进行测试,如果通过启动服务器,建立http client进行测试,这样会使得测试变得很麻烦,比如,启动速度慢,测试验证不方便 ...

  3. Spring MVC Hello World Example(转)

    Spring 3 You may interest at this Spring 3 MVC hello world example. In Spring MVC web application, i ...

  4. Spring MVC Integration,Spring Security

     http://docs.spring.io/spring-security/site/docs/4.2.0.RELEASE/reference/htmlsingle/#authorize-reque ...

  5. Spring MVC Hibernate MySQL Integration(集成) CRUD Example Tutorial【摘】

    Spring MVC Hibernate MySQL Integration(集成) CRUD Example Tutorial We learned how to integrate Spring ...

  6. 玩转单元测试之Testing Spring MVC Controllers

    玩转单元测试之 Testing Spring MVC Controllers 转载注明出处:http://www.cnblogs.com/wade-xu/p/4311657.html The Spri ...

  7. spring mvc 介绍

    Spring MVC Tutorial tag. * * If you do not want to deal with the intricities of the noscript * secti ...

  8. Spring mvc 4系列教程(一)

    一.Spring框架概览 Spring框架是一种轻量级.一站式解决企业级应用的解决方案.不仅如此,Spring的模块化的特点,可以使你只引用所需要的部分,而无需引用全部.你可以使用控制反转容器(IoC ...

  9. Spring Boot Reference Guide

    Spring Boot Reference Guide Authors Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch,  ...

随机推荐

  1. (转载)C++lambda表达式

    (转载)http://www.cnblogs.com/L-hq815/archive/2012/08/23/2653002.html lambda表达式 C++ 语言中的lambda表达式在很多情况下 ...

  2. NGINX(六)扩展

    前言 nginx模块化设计, 添加扩展模块变得容易, 下面开发一个非常简单的扩展模块, 实现返回http请求的头部内容, 配置标记是ping_pong, 配置在NGX_HTTP_LOC_CONF中. ...

  3. json解析之jackson ObjectMapper

    Json解析常用的有fastjson和jackson,性能上网上有不少的对比,说是fastjson比较好,今天先整理一下jackson的东西,后面再发一个fastjson的. jackson是spri ...

  4. 统计计算与R语言的资料汇总(截止2016年12月)

    本文在Creative Commons许可证下发布. 在fedora Linux上断断续续使用R语言过了9年后,发现R语言在国内用的人逐渐多了起来.由于工作原因,直到今年暑假一个赴京工作的机会与一位统 ...

  5. O(1)时间删除链表的已知结点

    这题并不需要从头结点遍历到已知结点,只需要知道已知结点,将改结点下一个结点赋值给它,再删除这个下一个结点就行,其中还需要考虑各种情况. 1)链表为空或者已知结点为空 2)链表只有一个结点,这个结点就是 ...

  6. ACM2123(一个简单的问题)

    一个简单的问题 问题说明 在这个问题中,你需要做N * N的乘法表,就像样品.第第i 行和j 个列中的元素i和j的乘积(乘积).   输入 输入的第一行是一个整数C中表示测试用例的数量,然后C的测试用 ...

  7. C++ STL@ list 应用 (leetcode: Rotate Array)

    STL中的list就是一双向链表,可高效地进行插入删除元素. List 是 C++标准程式库 中的一个 类 ,可以简单视之为双向 连结串行 ,以线性列的方式管理物件集合.list 的特色是在集合的任何 ...

  8. 成功在BAE上部署ghost 5.0

    这周摸索着网站的建设,终于在今天成功上线!这里要谢谢ghost中文网和群里的网友,他的博客在这opengiser.他们的帮助太重要了.现在把过程记录下来,共同学习.试运营地址在edwardesire. ...

  9. .net iis 域名泛解析实战

    最近做个人网站想实现多个二级域名,一来为了好记,二来为了搜索引擎优化,搜索引擎对二级域名的收录还是比较快的.刚开始做了4,5个二级域名,每个都是在域名解析后台手动添加的,不过随着二级域名越来越多,发现 ...

  10. [OC Foundation框架 - 5] NSString的常用方法

             NSString *s1 = ";   1.比较 使用 == 号比较的是字符串地址 NSString *s4 = @"abcdefg"; NSStrin ...