Try putting @ActionMapping
rather than @ActionMapping("").
Defining default Portlet Action method
-
02-09-2022 - |
Вопрос
I am having some doubt regarding Spring MVC Portlet Controller.
I would like to define a controller, which will paint the portlet for the first time, any subsequent actions from the portlet will trigger respective action methods
@Controller("searchController")
@RequestMapping("VIEW")
public class SearchController {
@RenderMapping
public String showSearch(RenderRequest request, Locale locale, Model model) {
logger.info("Loading the Search Bar");
return "search";
}
@ActionMapping("") //default action that should be executed for first time
public void fetchSearchDetails(ActionRequest request, ActionResponse response, SessionStatus sessionStatus) {
logger.info("Searching the Refinement");
}
@ActionMapping("searchAction")
public void searchProduct(@Valid @ModelAttribute(value = "product") Product product, BindingResult bindingResult,
ActionRequest request, ActionResponse response, SessionStatus sessionStatus) {
//execute if actionURL is searchAction
}
}
How do I declare/call default Action method if the portlet is getting loaded for the first time or no action.
Решение
Другие советы
The first time the portlet is displayed, only the render phase is executed, not the action phase. So I guess you should take care of your default behavior in the render phase, and remove your default action method (fetchSearchDetails).
Не связан с StackOverflow