I'm trying to get friendly URL mapping to work for a Spring MVC portlet inside Liferay 6.1 and fail.
My additions to the liferay-portlet-xml
are according to the manual and blog examples available and as follows:
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>search</friendly-url-mapping>
<friendly-url-routes>com/.../friendly-url-routes.xml</friendly-url-routes>
with the friendly-url-routes.xml
being
<!DOCTYPE routes PUBLIC "-//Liferay//DTD Friendly URL Routes 6.1.0//EN"
"http://www.liferay.com/dtd/liferay-friendly-url-routes_6_1_0.dtd">
<routes>
<route>
<pattern>/{match}</pattern>
<generated-parameter name="foo">{match}</generated-parameter>
</route>
</routes>
My Spring MVC controller goes like
@Controller
@RequestMapping("VIEW")
public class CarModelController {
@ActionMapping
public void action(@RequestParam("foo") final String testParam,
final ActionRequest request, final ActionResponse response) {
this.logger.info("default action");
this.logger.info("testParam = {}", testParam);
}
@RenderMapping
public String render(final RenderRequest request, final RenderResponse response) {
this.logger.info("default render");
return "index";
}
}
If I call my portlet using /baseurl/-/search/bar
only the render phase output occurs, the action method isn't called.
If I create a link to this page using
<portlet:actionURL var="lastStepUrl">
<portlet:param name="foo" value="bar" />
</portlet:actionURL>
the URL Liferay generates looks like /baseurl/-/search/bar?p_auth=sometoken&p_p_lifecycle=1
. It executes the action phase correctly and I'm also able to call that URL directly. It does, however, include the p_auth
and p_p_lifecycle
parameters that I want to get rid of.
Any suggestions are welcomed warmly.
portlet:actionUrl
is generating as apposed to what happens when you call it directly using something like Chrome's dev tools or FireFox's FireBug. You could then use something curl, start with an exact copy of the request that works, then start removing things until it stops working. This would identify what is causing one request to trigger and another to not. Things to look for: HTTP Request Type (POST/GET/etc.), any headers being sent, any POST/GET vars being sent, etc. – CodeChimp