当前位置: 首页 > 工具软件 > Jahia > 使用案例 >

关于整合SSH2项目到Jahia中

云隐水
2023-12-01
最近公司的项目涉及到了将做好的项目整合到Jahia中,所有我做了一个小的Demo测试了一下Jahia的view mode,关于Jahia是什么请到 http://www.jahia.com/jahia/Jahia 中了解。步骤如下:
 1.在WEB-INF/下添加portlet.xml文件.以我的NewsDemo为例
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
  3. <portlet>
  4.     <portlet-name>NewsTest Portlet</portlet-name>
  5.     <display-name>News Test Portlet</display-name>
  6.   <portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
  7.   <init-param>
  8.       <name>viewNamespace</name>
  9.       <value>/view</value>
  10.     </init-param>
  11.    <init-param>
  12.       <name>defaultViewAction</name>
  13.       <value>newsView!show</value>
  14.     </init-param>
  15.    <expiration-cache>0</expiration-cache>
  16.     <supports>
  17.       <mime-type>text/html</mime-type>
  18.       <portlet-mode>view</portlet-mode>
  19.     </supports>
  20.     <portlet-info>
  21.       <title>NewsTest Portlet</title>
  22.       <short-title>NewsTest Portlet</short-title>
  23.       <keywords>NewsTest Portlet</keywords>
  24.     </portlet-info>
  25. </portlet>
  26. </portlet-app>
其中:
  1.  <init-param>
  2.        <name>viewNamespace</name>
  3.        <value>/view</value>
  4.      </init-param>

  5.     <init-param>
  6.        <name>defaultViewAction</name>
  7.        <value>newsView!show</value>
  8.     </init-param>
viewNamespace定义action的namespace  类似的还有editNamespace,helpNamespace。
defaultViewAction为Portlet启动后默认执行的action名.如果定义action的时候 类似 newsView!*这种的话,要写newsView,此时Portlet将会去寻找acton的execute()方法,否则直接写成newsView!show。
 2. 修改struts.xml文件,以我的NewsDemo为例
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE struts PUBLIC  
  3.      "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"  
  4.      "http://struts.apache.org/dtds/struts-2.0.dtd">
  5. <struts>
  6.     <include file="struts-portlet-default.xml" />
  7.    <package name="newsViewDemo" extends="struts-portlet-default" namespace="/view">
  8.         <action name="newsView!*" class="newsViewAction" method="{1}">
  9.             <result name="input">/view/list.jsp</result>
  10.             <result name="detail">/view/detail.jsp</result>
  11.             <result name="classnewslist">/view/classnewslist.jsp</result>
  12.         </action>
  13.     </package>
  14. </struts>
package 的namespace可以写成别的,这样的话 viewNamespace也要做相应的变化。
其中要注意的有:
  1. 添加 <include file="struts-portlet-default.xml" />
  2. 将extens 改为 : extends="struts-portlet-default"
  3. 路径要写成绝对的形式如:/view/list.jsp
 3.将项目打成war包放到$jahiahome/tomcat/webapps/jahia/WEB-INF/var/new_webapp/下,jahia会自动调用。


 类似资料: