[英]JSP / Controller not found for custom component in Hybris addon
I'm running Hybris 6.6 and are building a new addon, that is basically a controller and corresponding JSP.我正在运行 Hybris 6.6 并且正在构建一个新的插件,它基本上是一个控制器和相应的 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).然而,在运行时,Hybris 没有找到控制器 bean 并在店面文件夹中搜索 JSP(它不存在,因为 JSP 位于店面插件文件夹中)。
I created the addon using extgen, and then installed it in the storefront using also ant.我使用 extgen 创建了插件,然后也使用 ant 将其安装在店面中。
Steps:脚步:
I've debuged the code, and when Hybris tries to find if there is a controller via getBeanFactory().contains(controller) it returns false.我已经调试了代码,当 Hybris 尝试通过 getBeanFactory().contains(controller) 查找是否有控制器时,它返回 false。 If I look at the bean list that the bean factory returns, the bean for the controller is not there.如果我查看 bean 工厂返回的 bean 列表,则控制器的 bean 不在那里。
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.我什至试图在 -web-spring.xml 上显式创建控制器 bean,但没有改变任何东西。
Thank you谢谢
Make sure确保
GenericCMSAddOnComponentController
or AbstractCMSAddOnComponentController
for the compoent inside addon.您的控制器应该为插件内部的组件扩展GenericCMSAddOnComponentController
或AbstractCMSAddOnComponentController
。Annotate the Controller with注释控制器
@Controller(YourComponentController) @RequestMapping(value="/view/YourComponentController")
Add your jsp to *addon/web/webroot/*/view/*/cms/yourcomponentname.jsp
.将您的 jsp 添加到*addon/web/webroot/*/view/*/cms/yourcomponentname.jsp
。 Refer getView method of AbstractCMSAddOnComponentController for the path路径参考 AbstractCMSAddOnComponentController 的 getView 方法
*-web-spring.xml
should be in resource folder/path *-web-spring.xml
应该在资源文件夹/路径中
component scan should be added for your controller in *-web-spring.xml
应该在*-web-spring.xml
为您的控制器添加组件扫描
<context:component-scan base-package="my.path.controllers"/>
*-web-spring.xml
should be configured in additionalWebSpringConfigs properties. *-web-spring.xml
应该在 additionalWebSpringConfigs 属性中配置。 Refer your addon project.properties参考你的插件 project.properties
like myCustomstorefront.additionalWebSpringConfigs.MyAddonName=classpath:/XXX/web/spring/*-web-spring.xml
像myCustomstorefront.additionalWebSpringConfigs.MyAddonName=classpath:/XXX/web/spring/*-web-spring.xml
In addition to the excellent instructions by HybrisHelp, it's likely that others coming across this question need to add this to the *-web-spring.xml除了 HybrisHelp 的出色说明外,遇到此问题的其他人很可能需要将此添加到 *-web-spring.xml
scope-resolver="de.hybris.platform.spring.IgnoreTenantScopeMetadataResolver"
so it looks like所以它看起来像
<context:component-scan base-package="my.path.controllers" scope-resolver="de.hybris.platform.spring.IgnoreTenantScopeMetadataResolver" />
Only with this attribute, the controller was loaded for me.只有这个属性,控制器才为我加载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.