Terry.Li-彬

          虛其心,可解天下之問(wèn);專(zhuān)其心,可治天下之學(xué);靜其心,可悟天下之理;恒其心,可成天下之業(yè)。

            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            143 隨筆 :: 344 文章 :: 130 評(píng)論 :: 0 Trackbacks
          <2008年3月>
          2425262728291
          2345678
          9101112131415
          16171819202122
          23242526272829
          303112345

          常用鏈接

          留言簿(19)

          隨筆分類(lèi)(107)

          隨筆檔案(141)

          文章分類(lèi)(284)

          文章檔案(342)

          相冊(cè)

          收藏夾(58)

          家裝

          最新隨筆

          搜索

          積分與排名

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

           

          用戶在地址欄鍵入http://localhost:8080/后,整個(gè)Liferay系統(tǒng)發(fā)生了些什么呢?

          1. 第一步,生成 http://localhost:8080/c
          Request:   GET/HTTP/1.1
          Response: 
          狀態(tài):HTTP/1.1 200 OK
          內(nèi)容:... <body onload="javascript:location.replace('/c')"> ...

          解釋?zhuān)?/u>
          在web.xml中有關(guān)于首頁(yè)的定義如下,也就是說(shuō)當(dāng)用戶敲入http://localhost:8080/所調(diào)用的頁(yè)面。

          web.xml
          --------
          <welcome-file-list>
            <welcome-file>index.html</welcome-file>
            <welcome-file>index.jsp</welcome-file>
          </welcome-file-list>

          在index.jsp中有如下內(nèi)容,所以可以知道Response的內(nèi)容如何得來(lái)。

          index.jsp
          ----------
          <%@ page import="com.liferay.portal.util.PortalUtil" %>
          <html>
          <head>
            <title></title>
            <meta content="0; url=<%= PortalUtil.getPathMain() %>" http-equiv="refresh">
          </head>
          <body onload="javascript:location.replace('<%= PortalUtil.getPathMain() %>')">
          </body>
          </html>


          2. 第二步,生成 http://localhost:8080/c/portal/layout

          Request:   GET/c HTTP/1.1
          Response:
          狀態(tài):HTTP/1.1 302 Moved Temporarily
          頭部:Location: http://10.108.10.205:8080/c/portal/layout

          解釋?zhuān)?br /> 當(dāng)服務(wù)器收到"GET/c"請(qǐng)求后,根據(jù)web.xml中的定義,請(qǐng)求會(huì)送入MainServlet進(jìn)行處理。如何生成"/c/portal/layout"有待分析,以后補(bǔ)充,還好不影響大局。

          web.xml
          --------
          <servlet-mapping>
            <servlet-name>MainServlet</servlet-name>
            <url-pattern>/c/*</url-pattern>
          </servlet-mapping>


          3. 第三步,生成 http://10.108.10.205:8080/web/guest/home
          Request:   GET/c/portal/layout HTTP/1.1
          Response:
          狀態(tài):HTTP/1.1 302 Moved Temporarily
          頭部:Location: http://10.108.10.205:8080/web/guest/home

          解釋?zhuān)?/u>
          當(dāng)服務(wù)器收到請(qǐng)求后,同樣會(huì)送到MainServlet處理,然后會(huì)傳遞到LayoutAction, layout.jsp, portlet.jsp, TemplateProcessor, PortletColumnLogic, load_render_portlet.jsp, portlet_js.jspf,等等,很漫長(zhǎng)的,也很有確的一個(gè)過(guò)程,后面會(huì)有單獨(dú)的分析,中間仍有一些不明朗的地方,仍有待挖掘。不過(guò)不妨礙理清 Liferay的大致經(jīng)絡(luò)。


          4. 第四步,生成網(wǎng)頁(yè)
          Request:   GET /web/guest/home HTTP/1.1
          Response: 
          狀態(tài):HTTP/1.1 200 OK
          內(nèi)容:
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
              <html dir="ltr">\n
              <head>\n
              <title>liferay.com - Welcome</title>\n
              <meta content="text/html; charset=UTF-8" http-equiv="content-type" />\r
              <link rel="Shortcut Icon" href="/html/themes/classic/images/liferay.ico" _fcksavedurl=""/html/themes/classic/images/liferay.ico"" />\r
              <link href="/c/portal/css_cached?themeId=classic&colorSchemeId=01&t=1203549390654" type="text/css"

          rel="stylesheet" />\r
              <style type="text/css">\r
              </style>\r
              <script type="text/javascript">\r
              var themeDisplay = {\r
              getCompanyId: function() {\r
              return "10094";\r
              },\r
          ......

          解釋?zhuān)?br /> 在web.xml中有定義,所以"GET /web/guest/home"請(qǐng)求會(huì)由FriendlyURLServlet處理。

          web.xml
          --------
          <servlet>
            <servlet-name>FriendlyURLPublicServlet</servlet-name>
            <servlet-class>com.liferay.portal.servlet.FriendlyURLServlet</servlet-class>
            <init-param>
              <param-name>private</param-name>
              <param-value>false</param-value>
            </init-param>
            <load-on-startup>4</load-on-startup>
          </servlet>
          <servlet-mapping>
            <servlet-name>FriendlyURLPublicServlet</servlet-name>
            <url-pattern>/web/*</url-pattern>
          </servlet-mapping>

          在FriendlyURLServlet.service()方法中,再次將請(qǐng)求傳遞到/c/portal/layout,由LayoutAction進(jìn)行后續(xù)處理。

          FriendlyURLServlet.service()
          -----------------------------
          ServletContext ctx = getServletContext();
          String mainPath = PortalUtil.PATH_MAIN;
          String redirect = mainPath; //redirect = "/c/portal/layout..."
          ......
          RequestDispatcher rd = ctx.getRequestDispatcher(redirect);
          rd.forward(req, res);

           

          Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2177392

          主站蜘蛛池模板: 东莞市| 公安县| 海南省| 大安市| 新营市| 汨罗市| 红桥区| 玉环县| 崇州市| 佛山市| 岑溪市| 巫溪县| 谷城县| 夏津县| 上高县| 青岛市| 杨浦区| 广东省| 县级市| 小金县| 溆浦县| 巴彦淖尔市| 新竹市| 密山市| 曲沃县| 美姑县| 七台河市| 武安市| 黎平县| 锡林浩特市| 巴楚县| 上虞市| 府谷县| 遂昌县| 巨野县| 禹州市| 县级市| 宾阳县| 南华县| 定日县| 丹寨县|