【问题标题】:404 -resource under sub-directory not found in eclipse404 - 在 Eclipse 中找不到子目录下的资源
【发布时间】:2013-05-15 05:50:43
【问题描述】:

只有当资源(比如 test.html)直接位于 eclipse 中的 WebContent 下时,我才能访问它。如果我将它放在 WEB-INF 或 WEB-INF/jsp 中,IDE 会显示错误 404-requested resource is not可用。

 http://localhost:8080/MyApp/test.html (This works when test.html is under WebContent and not any of it's subdirectory)

当它在 WebContent/WEB-INF 中时 右键运行到下面的 URL 显示 404-resource not available

       http://localhost:8080/MyApp/WEB-INF/test.html

如何通过在 WEB-INF 或 WEB-INF/jsp 中放置“test.html”来访问它?

所有配置都是默认的,在 web.xml 中没有指定限制,并且使用 Tomcat 7 作为 Web 服务器

【问题讨论】:

    标签: eclipse tomcat


    【解决方案1】:

    防止访问特定文件。您不能从服务器本身外部访问 /WEB-INF/ 目录。如果要创建子目录,请在

    下创建它们

    网络应用程序/ -index.jsp -你的子目录/ --test.jsp

    test.jsp 可以通过 localhost:8080/MyApp/YourSubdirectory/test.jsp 访问

    【讨论】:

      【解决方案2】:

      WEB-INF 目录下的文件不能直接从浏览器访问。这是基本的限制。

      但是,可以在应用程序级别访问此目录的内容。 Web 容器提供了这样的机会。

      例如,如果您使用 SpringMVC,您可以将一些 URL 映射到 WIB-INF 目录下的文件,它会正常工作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-06-08
        • 2015-10-18
        • 2013-06-21
        • 1970-01-01
        • 2015-05-26
        • 1970-01-01
        相关资源
        最近更新 更多