Documentation
Liferay provides a rich store of resources and knowledge to help our community better use and work with our technology.
Optional: Adding Friendly URL Mapping to the Portlet
You will notice that when you click the Edit greeting link, you are taken to a page with a URL similar to this:
http://localhost:8080/web/guest/home?p_p_id=mygreeting_WAR_mygreetingportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&_mygreeting_WAR_mygreetingportlet_jspPage=%2Fedit.jsp
In Liferay 6 there is a new feature that requires minimal work to change this into:
http://localhost:8080/web/guest/home/-/my-greeting/edit
This feature, known as friendly URL mapping, takes unnecessary parameters out of the URL and allows you to place the important parameters in the URL path rather than the query string. To add this functionality, first edit liferay-portlet.xml and add the following lines directly after </icon> and before <instanceable>. Be sure to remove the line breaks and the backslashes!
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.Default\
FriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>my-greeting</friendly-url-mapping>
<friendly-url-routes>com/sample/mygreeting/portlet/my-greeting-friendly-url\
-routes.xml</friendly-url-routes>
Next, create the file (note the line break):
my-greeting-portlet/docroot/WEB-INF/src/com/sample/mygreeting/portlet/my\
-greeting-friendly-url-routes.xml
Create new directories as necessary. Place the following content into the new file:
<?xml version="1.0"?>
<!DOCTYPE routes PUBLIC "-//Liferay//DTD Friendly URL Routes 6.0.0//EN" "http://www.liferay.com/dtd/liferay-friendly-url-routes_6_0_0.dtd">
<routes>
<route>
<pattern>/{jspPageName}</pattern>
<generated-parameter name="jspPage">/{jspPageName}.jsp</generated-parameter>
</route>
</routes>
Redeploy your portlet, refresh the page, and try clicking either of the links again. Notice how much shorter and more user-friendly the URL is, without even having to modify the JSPs. For more information on friendly URL mapping, you can check full discussion of this topic in Liferay in Action.