Here is one of my controller method,
@ResourceMapping(value="petPortalAction")
@RequestMapping(params={"transactionType=BUY_PET"})
public String handlePetPurchaseAction(
@RequestParam(required=true, value="petId") String petId,
PortletRequest request,
Model model)
{
...
}
As you can see, parameter petId is mandatory request parameter.
If it’s missing from the request, org.springframework.web.portlet.bind.MissingPortletRequestParameterException will be raised.
My question is how to catch and handle this exception… Is there any listener in spring that I can use?
Thanks in advance.
The question is somewhat old, but I had the same problem (and this question comes up pretty high on Google ;-)). So here is what I did:
I added the follwing to my applicationContext.xml:
The error/error-missing-parameter is the name of a view that is to be displayed. Spring will automatically publish the exception to the view, by default calling the variable “exception”. On a typical JSP setup that I have the view error/error-missing-parameter maps to /WEB-INF/jsp/error/error-missing-parameter.jsp depending on your view resolver configuration. This file can for example simply look like this:
The property “defaultErrorView” maps to a view in case that none of the exceptionMappings below matches. If you don’t need this, than you can skip this property.