求教!springmvc tomcat一切正常,weblogic 下controller无法访问到页面

道在何方 发布于 2015/11/02 19:15
阅读 2K+
收藏 0

项目在tomcat下运行正常,现在要迁移到weblogic11上。

现象:

1)get请求,返回这种模式:@ResponseBody,返回字符串,能够返回成功。

2)get请求,返回这种模式:ModelAndView,返回个html页面,报如下异常:

    Root cause of ServletException.
java.lang.NullPointerException
at weblogic.utils.io.FilenameEncoder.resolveRelativePath(FilenameEncoder.java:279)
at weblogic.utils.io.FilenameEncoder.resolveRelativeURIPath(FilenameEncoder.java:267)
at weblogic.utils.classloaders.ZipClassFinder.getSource(ZipClassFinder.java:36)
at weblogic.utils.classloaders.AbstractClassFinder.getSources(AbstractClassFinder.java:12)
at weblogic.utils.classloaders.JarClassFinder.getSources(JarClassFinder.java:56)
at weblogic.utils.classloaders.MultiClassFinder.getSources(MultiClassFinder.java:77)
at weblogic.utils.classloaders.MultiClassFinder.getSources(MultiClassFinder.java:77)
at weblogic.utils.classloaders.MultiClassFinder.getSources(MultiClassFinder.java:77)
at weblogic.application.utils.CompositeWebAppFinder.getSources(CompositeWebAppFinder.java:80)
at weblogic.utils.classloaders.MultiClassFinder.getSources(MultiClassFinder.java:77)
at weblogic.utils.classloaders.MultiClassFinder.getSources(MultiClassFinder.java:77)
at weblogic.utils.classloaders.CodeGenClassFinder.getSources(CodeGenClassFinder.java:38)
at weblogic.utils.classloaders.GenericClassLoader.findResources(GenericClassLoader.java:243)
at java.lang.ClassLoader.getResources(ClassLoader.java:1185)
at org.apache.velocity.tools.ClassUtils.addResources(ClassUtils.java:201)
at org.apache.velocity.tools.ClassUtils.getResources(ClassUtils.java:143)
at org.apache.velocity.tools.config.ConfigurationUtils.findInClasspath(ConfigurationUtils.java:359)
at org.apache.velocity.tools.config.ConfigurationUtils.findInClasspath(ConfigurationUtils.java:344)
at org.apache.velocity.tools.config.ConfigurationUtils.find(ConfigurationUtils.java:298)
at org.apache.velocity.tools.ToolManager.findConfig(ToolManager.java:108)
at org.apache.velocity.tools.ToolManager.configure(ToolManager.java:95)
at com.dditax.core.ext.VelocityToolbox20View.createVelocityContext(VelocityToolbox20View.java:28)
at org.springframework.web.servlet.view.velocity.VelocityView.renderMergedTemplateModel(VelocityView.java:288)
at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

spring mvc配置文件:<bean id="viewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="requestContextAttribute" value="rc" />
<property name="cache" value="false" />
<property name="prefix" value="" />
<property name="suffix" value=".html" />
<property name="contentType">
<value>text/html;charset=UTF-8</value>
</property>
<property name="exposeSpringMacroHelpers" value="true" />
<property name="toolboxConfigLocation">
<value>WEB-INF/configuration/velocity-toolbox.xml</value>
</property>
</bean>
<bean id="velocityConfig" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath">
<value>/</value>
</property>
<property name="velocityProperties">
<props>
<prop key="directive.foreach.counter.name">velocityCount</prop>
<prop key="$foreach.index">0</prop>
<prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop>
<prop key="contentType">text/html;charset=UTF-8</prop>
</props>
</property>
</bean>

controller里面返回写法:return new ModelAndView("WEB-INF/pages/xx.html", model);

看异常应该是找不到路径的问题,请问谁知道在weblogic里面怎么改?多谢!!!!!!

注释:刚刚测试了下,故意写个不存在的页面,结果显示unable to find resource '4042.html' in any resource loader。。。由此推测不是没找到路径,而是找到路径后报的错误!

加载中
0
二的基本算合格
二的基本算合格

首先<property name="suffix" value=".html" />这行配置表示,返回的modelAndView的name中不含有后缀.html。

用下面的这个试试。

return new ModelAndView("WEB-INF/pages/xx", model);

还有,你这个Spring这个写法一般不这样些了。

@RestController 直接返回view字符串名就OK了,你这个写的太多了。当然了还是要看Spring的版本,最好参考优秀的例子写。

0
刘柳
刘柳
这种情况大部分是spring自带的第三方包好多weblogic也有,版本冲突导致的
返回顶部
顶部