在 Hybris 插件中找不到自定义组件的 JSP/控制器 [英] JSP / Controller not found for custom component in Hybris addon

查看:18
本文介绍了在 Hybris 插件中找不到自定义组件的 JSP/控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行 Hybris 6.6 并且正在构建一个新插件,它基本上是一个控制器和相应的 JSP.然而,在运行时,Hybris 没有找到控制器 bean,而是在店面文件夹中搜索 JSP(它不存在,因为 JSP 在店面插件文件夹中).

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).

我使用 extgen 创建了插件,然后也使用 ant 将其安装在店面中.

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

步骤:

  • 在 -items.xml 中创建的组件继承自 SimpleCMSComponent
  • 创建的控制器继承自 AbstractCMSController,
  • 在插件文件夹中创建 JSP,
  • 创建组件并通过 Imped 添加到页面槽中,
  • @Controller 的名称等于组件 + Controller"

我已经调试了代码,当 Hybris 尝试通过 getBeanFactory().contains(controller) 查找是否有控制器时,它返回 false.如果我查看 bean 工厂返回的 bean 列表,控制器的 bean 不存在.

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.

关于发生了什么的任何线索?我什至尝试在 -web-spring.xml 上显式创建控制器 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.

谢谢

推荐答案

确保

  • 您的控制器应该为插件内部的组件扩展 GenericCMSAddOnComponentControllerAbstractCMSAddOnComponentController.
  • 用注解控制器

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

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

将你的jsp添加到*addon/web/webroot/*/view/*/cms/yourcomponentname.jsp.路径参考 AbstractCMSAddOnComponentController 的 getView 方法

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

*-web-spring.xml 应该在资源文件夹/路径中

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

应该在 *-web-spring.xml

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

*-web-spring.xml 应在附加WebSpringConfigs 属性中进行配置.请参考您的插件 project.properties

*-web-spring.xml should be configured in additionalWebSpringConfigs properties. Refer your addon project.properties

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

这篇关于在 Hybris 插件中找不到自定义组件的 JSP/控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆