Required String parameter is not present

I ran into the issue when I try to use Liferay friendly url. Previously, I didn't get the entire idea of friendly url and also how spring mvc works.

Here is the steps:

1. My view.jsp has a link to detail.jsp page.

<portlet:renderURL var="getFullTextURL">
	<portlet:param name="myaction" value="fullText" />
	<portlet:param name="guid" value="${channelArticle.guid }"/>
	<portlet:param name="friendlyUrl" value="${channelArticle.friendlyUrl}" />
</portlet:renderURL> 
<a href="<%=getFullTextURL%>">
	<img src="${channelArticle.articleImageLink }" />
</a>

2. In my controller, I have a method to deal with the action.

@RenderMapping(params = "myaction=fullText")
	public String requestFullText(RenderRequest renderRequest, RenderResponse renderResponse, @RequestParam String guid, @RequestParam String friendlyUrl) throws Exception {
//code...}


3. Friendly url mapping.

<routes>
	<route>
		<pattern>/{friendlyUrl}.html</pattern>
		<ignored-parameter name="guid"/>
		<implicit-parameter name="myaction">fullText</implicit-parameter>
	 </route>
</routes>

In this case, it reports the error "Required String parameter is not present". This is because our friendly url mapping, there's no param named guid, so the method in the controller can't get the value of guid. This is an error which Spring reports other than Liferay.

@RenderMapping(params = "myaction=fullText")
	public String requestFullText(RenderRequest renderRequest, RenderResponse renderResponse, @RequestParam String friendlyUrl) throws Exception {
//code
}
When we change method signature like this, it works.



你可能感兴趣的:(spring,url,liferay,liferay,friendly,RequestParam)