Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are 'parameters map' in NoHandlerFoundException set?

I'm trying to work out why below exception is thrown.

I think it is because a portlet was accessed in 'view' mode but for a reason I do not know the spring servlet container was unable to serve the request, is this correct ?

Where are the 'parameters map' in below exception set ?

org.springframework.web.portlet.NoHandlerFoundException: No matching handler method found for portlet request: mode 'view', phase 'ACTION_PHASE', parameters map[empty]

Here is the controller :

@Controller
@RequestMapping("VIEW")
public class DetailsController {
    @RequestMapping("VIEW")
    public String showDetails(final ModelMap modelMap, final RenderRequest renderRequest) {
        return "allDetails/details";
    }
}
like image 784
blue-sky Avatar asked Oct 05 '12 10:10

blue-sky


2 Answers

Here are 3 ideas I can come up with (knowing how your controller is called would help). Try one of them, or a mix of them, and tell me if it worked.

Idea 1 : Remove ("VIEW") for the showDetails @RequestMapping annotation.

...
public class DetailsController {

    @RequestMapping
    public String showDetails(final ModelMap modelMap, final RenderRequest renderRequest) {
        return "allDetails/details";
    }

}

This could work if your calling JSP has something like this : <portlet:actionURL/> : showDetails would be the default render method.

Idea 2 : Specify the action parameter for your @RequestMapping method annotation.

...
public class DetailsController {

    @RequestMapping(params = "action=viewDetails")
    public String showDetails(final ModelMap modelMap, final RenderRequest renderRequest) {
        ...
    }

}

This could work if your calling JSP has something like this :

<portlet:actionURL ... >
    <portlet:param name="action" value="viewDetails">
</portlet:actionURL>

Idea 3 : Add an empty method for the action phase.

...
public class DetailsController {

    @RequestMapping(params = "action=viewDetails")    // render phase
    public String showDetails(final ModelMap modelMap, final RenderRequest renderRequest) {
        ...
    }

    ...
    // Empty method
    @RequestMapping(params = "action=viewDetails")    // action phase
    public void actionMethod() {
    }

}

This could work if your calling JSP has something like this :

<portlet:actionURL ... >
    <portlet:param name="action" value="viewDetails">
</portlet:actionURL>
like image 198
Jerome Dalbert Avatar answered Sep 17 '22 14:09

Jerome Dalbert


Couple of things to check here first:

  1. Are there any parameters passed across to controller from jsp?
  2. Is there a default Action method to handle empty param scenario?

Now if answer to first question is yes, then your jsp should have actionURL tag something like...

        <portlet:actionURL var="myAction">
           <portlet:param name="paramName" value="paramVal" />
        </portlet:actionURL>
        <form:form action="${myAction}"...

and its corresponding ActionMapping in Controller like...

        @ActionMapping(params = "paramName=paramVal" )
        public void myAction....

And if answer to second question is no, then define a default action method in the Controller like...

       @ActionMapping(param="!action") 
       public void defaultAction....

Hope this helps!

like image 36
mod Avatar answered Sep 17 '22 14:09

mod