Spring MVC-无法获取RequestDispatcher [英] Spring MVC - Could not get RequestDispatcher

查看:732
本文介绍了Spring MVC-无法获取RequestDispatcher的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Spring MVC应用程序出现问题.

I got a problem on my Spring MVC application.

问题发生在Linux服务器上,本地(Windows 7 + eclipse)上,一切正常.

The problem only happens on the linux server, on local (windows 7 + eclipse), everything works fine.

当我访问我的页面时,控制器被称为,但是当服务器必须为jsp页面提供服务时,我就会得到:

When I access my page, the controller is called but when the server has to serve the jsp page, i've got :

HTTP Status 500 - Could not get RequestDispatcher for [/WEB-INF/pages/index.jsp]: Check that the corresponding file exists within your web application archive!

文件存在,路径很好.

这是我的web.xml的摘录

Here an extract from my web.xml

    <servlet>
    <servlet-name>cms-admin-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>cms-admin-dispatcher</servlet-name>
        <url-pattern>/do/*</url-pattern>
  </servlet-mapping>


  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/cms-admin-dispatcher-servlet.xml</param-value>
  </context-param>

和我的servlet调度程序:

and my servlet dispatcher :

<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/pages/" />
    <property name="suffix" value=".jsp" />
</bean>

我尝试用* .html替换我的/do/*模式,但没有任何变化. 我还尝试将jsp放在WEB-INF之外.

I tried to replace my /do/* pattern by *.html but there is no change. I also tried to put my jsp outside WEB-INF.

我尝试过:

<servlet>
        <servlet-name>jsp</servlet-name>
    <jsp-file>/WEB-INF/pages/index.jsp</jsp-file>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>

</servlet>

<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>/toto</url-pattern>
</servlet-mapping>

可以,jsp页面已加载,但资源未加载.

That works, the jsp page is loaded but not resources.

另外,我无法直接访问任何js文件(WEB-INF外部的resources/js/logs.js).我得到一个404,在本地我得到了我的文件.

Other thing, I am unable to access any js file directly (resources/js/logs.js, outside the WEB-INF). I get a 404, on local I get my file.

我完全不知道这是哪里来的,同样,它在我的本地计算机上也能很好地工作. tomcat的配置很常见.因此,感谢您提出任何建议.

I have pretty no idea where this is coming from, again, it works perfectly on my local. The tomcat config is pretty common. so thanks for advance for any ideas.

推荐答案

Tomcat无法在war文件中找到jsp 帖子给了我问题.

缺少默认的web.xml(在$ CATALINA_BASE/conf/web.xml上).结果是默认操作和servlet的配置不正确.

The default web.xml (on the $CATALINA_BASE/conf/web.xml) was missing. The result was that default operation and servlet wasn't properly made up.

http://tomcat.apache.org/tomcat-7.0 -doc/default-servlet.html

我刚刚将其添加到了tomcat的conf文件夹中,以解决此问题.

I just added it to the conf folder of my tomcat to fix the problem.

这篇关于Spring MVC-无法获取RequestDispatcher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆