绕过 grails 视图解析器?
我正在尝试在 grails 应用程序中构建一个 portlet,并且创建了一个扩展 AbstractController
的简单控制器,它
从 返回
。我还有一个针对 new ModelAndView('myportlet')
处理请求内部/WEB-INF/jsp
的标准 Jstl 视图解析器
设置,但无论我尝试什么,当我尝试在 liferay 中查看 portlet 时,我都会得到以下信息stacktrace:
13:19:39,723 ERROR [DispatcherPortlet:559] Could not complete request
java.lang.ClassCastException: org.springframework.web.portlet.context.PortletRequestAttributes cannot be cast to org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest
at org.codehaus.groovy.grails.web.util.WebUtils.retrieveGrailsWebRequest(WebUtils.java:497)
at org.codehaus.groovy.grails.web.servlet.view.GrailsViewResolver.loadView(GrailsViewResolver.java:87)
at org.codehaus.groovy.grails.scaffolding.view.ScaffoldingViewResolver.loadView(ScaffoldingViewResolver.java:61)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:158)
at org.springframework.web.servlet.view.UrlBasedViewResolver.createView(UrlBasedViewResolver.java:384)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:77)
at org.springframework.web.portlet.DispatcherPortlet.resolveViewName(DispatcherPortlet.java:1110)
看来如果我能够绕过 GrailsViewResolver,我应该能够像在正常的 Spring 应用程序中一样启动并运行我的 portlet。
我使用的是 liferay 6,所以 grails liferay 插件不是一个选项。我可以做些什么来确保 GrailsViewResolver 不会尝试解析 /WEB-INF/jsp
中的视图?
I'm trying to build a portlet within a grails application, and I've created a simple controller extending AbstractController
which returns
new ModelAndView('myportlet')
from handleRequestInternal
. I also have a standard Jstl view resolver
setup for /WEB-INF/jsp
but no matter what I try, when I try to view the portlet within liferay I get the following stacktrace:
13:19:39,723 ERROR [DispatcherPortlet:559] Could not complete request
java.lang.ClassCastException: org.springframework.web.portlet.context.PortletRequestAttributes cannot be cast to org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequest
at org.codehaus.groovy.grails.web.util.WebUtils.retrieveGrailsWebRequest(WebUtils.java:497)
at org.codehaus.groovy.grails.web.servlet.view.GrailsViewResolver.loadView(GrailsViewResolver.java:87)
at org.codehaus.groovy.grails.scaffolding.view.ScaffoldingViewResolver.loadView(ScaffoldingViewResolver.java:61)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:158)
at org.springframework.web.servlet.view.UrlBasedViewResolver.createView(UrlBasedViewResolver.java:384)
at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:77)
at org.springframework.web.portlet.DispatcherPortlet.resolveViewName(DispatcherPortlet.java:1110)
It seems that if I could get around the GrailsViewResolver
, I should be able to get my portlet up and running as I would in a normal spring application.
I'm using liferay 6, so the grails liferay plugin isn't an option. Is there anything I can do to make sure GrailsViewResolver doesn't try to resolve my view in /WEB-INF/jsp
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在使用 Grails,请 100% 使用它,并且不要尝试混合截然不同的技术。从长远来看,它会减轻你的痛苦。
If you're using Grails, use it 100% and don't try to mix wildly different technologies. It'll save you pain in the long run.