JSP / Controller not found for custom component in

2019-07-15 05:31发布

I’m running Hybris 6.6 and are building a new addon, that is basically a controller and corresponding JSP. During runtime however, Hybris isn’t finding the controller bean and searches for JSP in the storefront folder (it’s not there, since the JSP is in the storefront addon folder).

I created the addon using extgen, and then installed it in the storefront using also ant.

Steps:

  • Created component in -items.xml inheriting from SimpleCMSComponent
  • Created controller inheriting from AbstractCMSController,
  • Created JSP in addon folder,
  • Created component and added to page slot via Imped,
  • @Controller has the name equal to component + “Controller”

I’ve debuged the code, and when Hybris tries to find if there is a controller via getBeanFactory().contains(controller) it returns false. If I look at the bean list that the bean factory returns, the bean for the controller is not there.

Any clues on what’s happening? I’ve even tried to create the controller bean explicitly on the -web-spring.xml but doesn’t change anything.

Thank you

1条回答
倾城 Initia
2楼-- · 2019-07-15 06:01

Make sure

  • Your controller should extends GenericCMSAddOnComponentController or AbstractCMSAddOnComponentController for the compoent inside addon.
  • Annotate the Controller with

    @Controller(YourComponentController) @RequestMapping(value="/view/YourComponentController")

  • Add your jsp to *addon/web/webroot/*/view/*/cms/yourcomponentname.jsp. Refer getView method of AbstractCMSAddOnComponentController for the path

  • *-web-spring.xml should be in resource folder/path

  • component scan should be added for your controller in *-web-spring.xml

    <context:component-scan base-package="my.path.controllers"/>

  • *-web-spring.xml is there in additionalWebSpringConfigs properties. Refer your addon project.properties

    like myCustomstorefront.additionalWebSpringConfigs.MyAddonName=classpath:/XXX/web/spring/*-web-spring.xml

查看更多
登录 后发表回答