Liferay portlet 未调用正确的渲染方法(忽略 setRenderParameter)
我有一个包含许多呈现和操作方法的 portlet:
@Controller
@RequestMapping("VIEW")
public class CartController {
@RenderMapping() // default render method
public String defaultRender(RenderRequest req, RenderResponse res, Model model) throws PortalException, SystemException {
...
}
@RenderMapping(params="action=showCustInfo")
public String showCustInfo(RenderRequest req, RenderResponse res, Model model) throws PortalException, SystemException {
...
}
@ActionMapping(params="action=acceptCart")
public void acceptCart(ActionRequest req, ActionResponse res, Model model) throws PortalException, SystemException {
...
res.setRenderParameter("action", "showCustInfo");
...
}
在上面的代码中,方法 acceptCart 设置一个呈现参数,该参数应导致在呈现阶段调用 showCustInfo。
问题是每次都会调用默认渲染方法。我缺少什么?
I have a portlet which has many rendering and action methods:
@Controller
@RequestMapping("VIEW")
public class CartController {
@RenderMapping() // default render method
public String defaultRender(RenderRequest req, RenderResponse res, Model model) throws PortalException, SystemException {
...
}
@RenderMapping(params="action=showCustInfo")
public String showCustInfo(RenderRequest req, RenderResponse res, Model model) throws PortalException, SystemException {
...
}
@ActionMapping(params="action=acceptCart")
public void acceptCart(ActionRequest req, ActionResponse res, Model model) throws PortalException, SystemException {
...
res.setRenderParameter("action", "showCustInfo");
...
}
In the code above, the method acceptCart sets a render parameter that should cause showCustInfo to be called in rendering phase.
The problem is that the default rendering method gets called every time. What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因(看起来)是当我命令时 action 参数没有被替换
Spring 没有替换该值,而是为 action 参数添加了这个值,如下(伪):
此时,Spring似乎不知道该怎么做并调用默认的渲染方法。 我通过为渲染参数使用不同的参数名称(“render”)来解决这个问题。因此,现在动作由“action”参数调用,渲染器由“render”参数调用。
The reason (it seems) was that the action-parameter was not replaced when I commanded
Instead of replacing the value, Spring added this value for the action parameter as follows (pseudo):
At this point, Spring does not seem to know what to do and calls the default render method. I worked this around by using a different parameter name for the render parameter ('render'). Thus now actions get called by 'action'-parameter and renderers by 'render'-parameter.