【问题标题】:tomcat 7: The requested resource is not availabletomcat 7:请求的资源不可用
【发布时间】:2014-12-05 14:58:36
【问题描述】:

我正在使用 SpringMVC 和 Tomcat 编写一个全栈 Web 应用程序。当我运行该程序时,它似乎工作正常,没有错误消息,日志中没有任何内容。但是在 Postman 中,我得到的只是“请求的资源不可用”。这是我的 web.xml:

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://java.sun.com/xml/ns/javaee
        http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/business-config.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>

还有我的 mvc-dispatcher-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">

<mvc:annotation-driven />

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

</beans>

任何想法可能导致这种情况?

【问题讨论】:

  • 只是好奇:“全栈”Web 应用程序是什么意思?
  • 我的意思是它充分利用了 Spring 的 Model-View-Controller 堆栈。
  • 只是为了让您:这并不是该术语的真正用途。此外,不幸的是,您不太可能在这个问题上得到满意的答案,因为仅通过查看这两个 xml 文件(对我来说看起来不错)很难判断为什么会遇到这个问题。我可以建议使用 Spring Boot 设置您的项目,因为它使设置 Spring MVC/Tomcat 项目更加容易且不易出错。
  • 自己动手是一种学习体验。此外,Web 应用程序旨在根据需要进行扩展,它不仅仅是一个简单的 Web 应用程序。

标签: java tomcat


【解决方案1】:

如果使用 Eclipse,请尝试 Project>Clean...,然后右键单击您的 tomcat 服务器,在“Servers”视图中单击“Clean...”

【讨论】:

  • 好的,试过了,还是一样的错误信息。
猜你喜欢
  • 1970-01-01
  • 2015-03-09
  • 2017-01-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-18
  • 2010-12-04
相关资源
最近更新 更多