customComponentcontroller模型中的ClassCastException

时间:2016-07-07 12:44:30

标签: hybris

我创建了扩展SimpleCMSComponentModel的自定义ABC组件。 它在ABCComponentController中给出了类强制转换异常 - > fillModel

java.lang.ClassCastException:de.hybris.platform.cms2.model.contents.components.SimpleCMSComponentModel无法强制转换为ABCComponentController

任何建议都会有所帮助

1 个答案:

答案 0 :(得分:1)

您必须忘记将自定义模型从SimpleCMSComponentModel更改为ABCComponentModel。

这应该是这样的

@Controller("ABCComponentController")
@Scope("tenant")
@RequestMapping(value = ControllerConstants.Actions.Cms.ABCComponentController)
public class ABCComponentController extends AbstractCMSComponentController<ABCComponentModel>
{
    /**
    * Fill Model
    */
    @Override
    protected void fillModel(final HttpServletRequest request, final Model model, final ABCComponentModel component)
    {
      //
    }

}

其中

ControllerConstants.Actions.Cms.ABCComponentController = "/view/ABCComponentController";或您的自定义路径..