Liferay例子学习,如何部署简单的jsp portlet
?http://blog.chinaunix.net/space.php?uid=9195812&do=blog&id=2006478
?
Liferay例子學習 (2007-07-23 18:04) 分類: LifeRay1.????? 從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"?> |
?
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" %> </tr> |
修改D:\liferayPro\liferay-portal-pro-3.2.0-tomcat\webapps\test\WEB-INF\liferay-portlet.xml
粗體部分為要增加的portlet。
| <?xml version="1.0"?> 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的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 交通查询
- 下一篇: Liferay Portal学习笔记-c