日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

Liferay例子学习,如何部署简单的jsp portlet

發布時間:2024/4/17 54 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Liferay例子学习,如何部署简单的jsp portlet 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?http://blog.chinaunix.net/space.php?uid=9195812&do=blog&id=2006478

?

Liferay例子學習 (2007-07-23 18:04) 分類: LifeRay

1.????? 從Liferay官方網站www.liferay.com下載安裝文件liferay-portal-pro-3.2.0-tomcat.zip

?

在D盤創建liferayPro目錄,解壓縮liferay-portal-pro-3.2.0-tomcat.zip到D:\liferayPro\liferay-portal-pro-3.2.0-tomcat

設置環境變量$CATALINA_HOME= D:\liferayPro\liferay-portal-pro-3.2.0-tomcat

?

2.????? 安裝test.war

--------------以下引用liferay.com資料

Hot Deploy Portlet WARs

?

Liferay allows you to easily hot deploy JSR 168 compliant portlets. The following instructions deal with setting up your environment to use Ant to deploy the Test portlet or?other JSR 168 compliant portlets.

?

  • Create a portlets directory called /my_portlets.

    ?

  • Download test.war into /my_portlets. This WAR contains sample JSP and Struts portlets. You can also expand the WAR into /my_portlets/test.war to deploy an expanded WAR.

    Download portletsamples.war from?Sun into /my_portlets. All of the portlets work except for?the Weather Portlet because it requires JSP 1.2 and some of the application servers that Liferay supports do not yet support JSP 1.2.

    Download build.xml into /my_portlets. Make sure Ant 1.6.2 and JDK 1.4.2 is set up properly. See Development Environment for?instructions on setting up Ant and JDK.

    ?

  • Install either JBoss+Jetty, JBoss+Tomcat, Jetty, or?Tomcat.

    Edit build.xml to point to your application server or?servlet container. For?example, if you installed Tomcat to? /liferay, edit build.xml to make sure that only the Tomcat section is uncommented and set the property app.server.dir to liferay.

下載的build.xml文件并不一定能用,在這個例子里需要修改成如下:

?

<?xml version="1.0"?>
<project name="portlets" basedir="." default="deploy">
<target name="init">
<property environment="env" />
<property name="app.server.type" value="tomcat" />
<property name="app.server.dir" value="/liferayPro/liferay-portal-pro-3.2.0-tomcat" />
<property name="app.server.deploy.dir" value="${app.server.dir}/webapps" />
<path id="project.classpath">
<pathelement location="${env.ANT_HOME}/lib/ant.jar" />
<fileset dir="${app.server.dir}/common/lib/ext" />
<pathelement location="${app.server.dir}/common/lib/servlet-api.jar" />
</path>
</target>

<target name="deploy" depends="init">

?<java classname="com.liferay.portal.tools.PortletDeployer" classpathref="project.classpath" fork="true"

? newenvironment="true">

? <!-- Required Arguments -->

?
<jvmarg value="-Dportlet.deployer.base.dir=./" />

<jvmarg value="-Dportlet.deployer.dest.dir=${app.server.deploy.dir}" />

?<jvmarg value="-Dportlet.deployer.app.server.type=${app.server.type}" />
<jvmarg value="-Dportlet.deployer.taglib.dtd=${app.server.dir}/liferay/WEB-INF/tld/liferay-portlet.tld" />

<!-- Optional Arguments -->

?

?
<jvmarg value="-Dportlet.deployer.jboss.prefix=1" />

? <jvmarg value="-Dportlet.deployer.tomcat.lib.dir=${app.server.dir}/common/lib/ext" />
<!-- Dependent Libraries -->

? <arg value="${app.server.dir}/liferay/WEB-INF/lib/util-taglib.jar" />

? <arg value="${app.server.dir}/common/lib/util-java.jar" />

? </java>

?

</target>

?

</project>


?

3.????? 安裝Ant

下載Ant安裝文件 http://ant.apache.org

解壓縮到D:\ant\apache-ant-1.6.2

設置環境變量$ANT_HOME= D:\ant\apache-ant-1.6.2

增加 $ANT_HOME/bin 到 環境變量$PATH中

?

4.????? 進入到my_portlets 文件夾(假設在D:\liferayPro\),在Dos窗口下運行ant deploy命令。Ant 會根據build.xml中的設置把test.war部署到D:\liferayPro\liferay-portal-pro-3.2.0-tomcat\webapps\目錄下

輸出信息如下:

D:\liferayPro\my_portlets>ant deploy

?

Buildfile: build.xml

?

?

init:

?

?

deploy:

?

?

???? [java] Deploying test.war

?

???? [java]?? Expanding: .\test.war into 20050625121028802

?

???? [java] ??Modifying 20050625121028802\WEB-INF\web.xml

?

???? [java]?? Copying 69 files to D:\liferayPro\liferay-portal-pro-3.2.0-tomcat\webapps\test

?

???? [java]?? Deleting directory D:\liferayPro\my_portlets\20050625121028802

?

?

BUILD SUCCESSFUL

?

Total time: 3 seconds

?

D:\liferayPro\my_portlets>

?

?

?

5.????? 啟動 liferay server

D:\liferayPro\liferay-portal-pro-3.2.0-tomcat\bin\startup.bat

?

6.????? 測試test.war是否安裝成功

1)打開IE,輸入http://localhost

2)用戶:test@liferay.com 密碼:test

3)點擊Home

4)查看屏幕下方的下拉框中是否存在Test JSP和Test Struts

5)選中Test JSP,點擊Add按鈕,如果Test JSP portlet正確顯示說明test.war安裝好了

?

7.????? 接下來我們要創建一個自己的portlet -mytest

?

8.????? 新建一個jsp文件welcome.jsp

D:\liferayPro\liferay-portal-pro-3.2.0-tomcat\webapps\test\html\portlet\test_jsp\welcome.jsp

welcome.jsp內容如下:


<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>

?

?

<portlet:defineObjects />

?

?

<table cellpadding="8" cellspacing="0" width="100%">

?

<tr>

?

<td>

?

???????????<font class="gamma" size="2">

?

???????????Welcome to My Test Protlet

?

???????????</font>

?

</td>

?


</tr>

?

</table>


修改D:\liferayPro\liferay-portal-pro-3.2.0-tomcat\webapps\test\WEB-INF\liferay-portlet.xml

粗體部分為要增加的portlet。


<?xml version="1.0"?>

?

<!DOCTYPE portlets PUBLIC "-//Liferay//DTD PORTLET 2.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet_2_2_0.dtd">

?

?

<portlets>

?

<portlet id="test_jsp" struts-path="test_jsp" use-default-template="true" />

?

<portlet id="test_struts" struts-path="test_struts" use-default-template="true" restore-current-view="true" />

?

<portlet id="mytest_welcome" struts-path="mytest_welcome" use-default-template="true" />

?

<custom-user-attribute name="user.name.test" custom-class="com.liferay.portlet.teststruts.TestStrutsUserAttributes" />

?

</portlets>

10.? 修改D:\liferayPro\liferay-portal-pro-3.2.0-tomcat\webapps\test\WEB-INF\portel.xml

增加以下內容到portlet.xml文件中

?

<portlet>

?

?????????? <portlet-name>mytest_welcome</portlet-name>

?

?????????? <display-name>My Test Welcome</display-name>

?

?????????? <portlet-class>com.liferay.portlet.JSPPortlet</portlet-class>

?

?????????? <init-param>

?

??????????????????? <name>view-jsp</name>

?

??????????????????? <value>/portlet/test_jsp/welcome.jsp</value>

?

?????????? </init-param>

?

?????????? <expiration-cache>0</expiration-cache>

?

?????????? <supports>

?

??????????????????? <mime-type>text/html</mime-type>

?

?????????? </supports>

?

?????????? <portlet-info>

?

??????????????????? <title>Welcome to My Test Portlet</title>

?

??????????????????? <short-title>MyTest</short-title>

?

??????????????????? <keywords>MyTest</keywords>

?

?????????? </portlet-info>

?

?????????? <security-role-ref>

?

??????????????????? <role-name>Guest</role-name>

?

?????????? </security-role-ref>

?

?????????? <security-role-ref>

?

??????????????????? <role-name>Power User</role-name>

?

?????????? </security-role-ref>

?

?????????? <security-role-ref>

?

??????????????????? <role-name>User</role-name>

?

?????????? </security-role-ref>

?

</portlet>

?

?

11.? 修改D:\liferayPro\liferay-portal-pro-3.2.0-tomcat\webapps\test\WEB-INF\liferay-display.xml

增加以下內容:

?

<display>

?

<category name="category.mytest">

?

?????????? <portlet id="mytest_welcome" />

?

</category>

?

</display>

?

?

12.? 由于Liferay Portal Server采用的是ASP模式,一個服務器可以部署多個公司的Protal。在D:\liferayPro\liferay-portal-pro-3.2.0-tomcat\webapps\test\WEB-INF\web.xml中可是設置test.war屬于哪個公司,這里我們不改變web.xml的內容

<web-app>

?

<display-name>test</display-name>

?

<context-param>

?

?????????? <param-name>company_id</param-name>

?

?????????? <param-value>liferay.com</param-value>

?

</context-param>

?

…………..

?

</web-app>

?

?

13.? 重復第6步,看看下拉框中是否存在Welcome to My Test Portlet

?

總結

以上是生活随笔為你收集整理的Liferay例子学习,如何部署简单的jsp portlet的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。