Bypassing grails view resolvers?

天大地大妈咪最大 提交于 2019-12-24 03:04:15

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/5720927/bypassing-grails-view-resolvers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!