2012-04-15 38 views
1

我使用的Liferay 6.1的Liferay 6:能否Liferay的友好的URL,可以在我的情況下修改

我已經按照加入這個Liferay的-portet.xml文件

<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class> 
<friendly-url-mapping>Gasd</friendly-url-mapping> 
<friendly-url-routes>com/test/friendlier-friendly-url-routes.xml</friendly-url-routes> 

內,如上下文根(或portlet名稱),這是我的友好友好的URL-routes.xml

<routes> 
<route> 
    <pattern>/satportlet</pattern> 
</route> 
</routes> 

但仍是portlet的URL看起來這樣,當我做了一個提交作品

http://localhost:8086/web/guest/home/-/Gasd/satportlet?p_auth=EFAy7VSA&p_p_lifecycle=1&_satportlet_WAR_SatPractportlet_javax.portlet.action=addBook 

有無論如何,這是可以改善的。

我對Liferay非常陌生,請給我建議,我已經準備好按照你所說的去做。

回答

2

是的,它可以改進。

例如用於在JSP渲染URL,以在portlet視圖中的用戶:

<portlet:renderURL windowState="maximized" var="myURL"> 
    <portlet:param name="resourcePrimKey" value="<%=user.getUserId() %>" /> 
    <portlet:param name="jspPage" value="/html/viewMyUser.jsp" /> 
</portlet:renderURL> 

你可以在你的友好友好的URL-routes.xml這樣友好的URL路徑:

<route>         
    <pattern>/satportlet/{resourcePrimKey:\d+}/view</pattern> 
    <!-- \d+ is the place-holder for the userID, i.e. 5 in the friendly URL below --> 
    <implicit-parameter name="p_p_lifecycle">0</implicit-parameter> 
    <!-- Implicit parameters are not shown in the route pattern, here 0,1 etc are the phases of the portlet 0=render, 1=action etc --> 
    <implicit-parameter name="p_p_state">maximized</implicit-parameter> 
    <implicit-parameter name="jspPage">/html/viewMyUser.jsp</implicit-parameter> 
</route> 

所以產生友好的URL將是:

http://localhost:8086/web/guest/home/-/Gasd/satportlet/5/view 

在你的情況看你產生URL可以讓<路線>元素這樣的事情(如果<門戶:actionURL >或<的portlet:的renderURL >您正在使用的JSP被賦予我認爲這將是一個實用小建<路線>元) 。 我不知道,如果這將是完全正確的,但它會是這樣的:

<route> 
    <pattern>/satportlet/{p_auth}/{[p_p_id]_javax.portlet.action:\d+}</pattern> 
    <implicit-parameter name="p_p_lifecycle">1</implicit-parameter> 
</route> 

所以我想(我再次沒有足夠的肯定)上述配置應該生成友好的URL如:

http://localhost:8086/web/guest/home/-/Gasd/satportlet/EFAy7VSA/addBook 

您還可以檢查Liferay的源代碼和* - 友好的URL-routes.xml文件更好地瞭解。

希望這至少爲您提供了一個關於友好URL如何在liferay中工作的線索。

+0

非常感謝,這個網址看起來不錯。 – Gajjini 2012-04-16 11:47:27

+0

我很高興,它爲你工作。 – 2012-04-16 12:01:13

相關問題