Search code examples
javaspringspring-mvcportlet

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";
    }
}

Solution

  • 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>