[英]Defining default Portlet Action method
I am having some doubt regarding Spring MVC Portlet Controller. 我对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 我想定义一个控制器,该控制器将首次绘制portlet,portlet中的任何后续操作将触发各自的操作方法
@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. 如果portlet是第一次加载或没有任何动作,如何声明/调用默认的Action方法。
尝试放置@ActionMapping
而不是@ActionMapping("").
The first time the portlet is displayed, only the render phase is executed, not the action phase. 第一次显示portlet时,仅执行渲染阶段,而不执行操作阶段。 So I guess you should take care of your default behavior in the render phase, and remove your default action method (fetchSearchDetails).
因此,我想您应该在呈现阶段照顾默认行为,并删除默认操作方法(fetchSearchDetails)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.