Java 404 NoTargetForURIException 访问 Websphere 7 下的 WebContent 文件夹中的静态资源

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19882354/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 21:00:57  来源:igfitidea点击:

404 NoTargetForURIException accessing static resources in WebContent folder under Websphere 7

javaservletswebsphere-7

提问by Rob Darwin

In an Eclipse web project targeting WebSphere Application Server 7, I have CSS files in a css subfolder under WebContent. When I try to access them from a browser I get a 404 error saying:

在面向 WebSphere Application Server 7 的 Eclipse Web 项目中,我在 WebContent 下的 css 子文件夹中有 CSS 文件。当我尝试从浏览器访问它们时,我收到 404 错误消息:

Error 404: com.ibm.ws.webcontainer.servlet.exception.NoTargetForURIException: No target servlet configured for uri: /css

采纳答案by Rob Darwin

The solution was to enable file serving in ibm-web-ext.xml.

解决方案是在 ibm-web-ext.xml 中启用文件服务。

  1. Double-click on web.xml to open up the Web Application Deployment Description Editor.
  2. Select the "Open WebSphere Extensions Descriptor" link.
  3. Select the "Enable File Serving" checkbox and save your changes.
  1. 双击 web.xml 打开 Web 应用程序部署描述编辑器。
  2. 选择“打开 WebSphere 扩展描述符”链接。
  3. 选中“启用文件服务”复选框并保存更改。

This adds the following line to ibm-web-ext.xml:

这会将以下行添加到 ibm-web-ext.xml:

<enable-file-serving value="true"/>

Acknowledgement to CodeRanch for the solution.

感谢 CodeRanch 提供解决方案。

回答by karl

Another way to get this error is if your path name after the host is wrong. For example if you are deploying an EAR, and try to hit the name of the EAR. You have to make sure make sure the path matches the web application name exactly.

获得此错误的另一种方法是您的主机后的路径名是否错误。例如,如果您正在部署一个 EAR,并尝试点击 EAR 的名称。您必须确保路径与 Web 应用程序名称完全匹配。

enter image description here

在此处输入图片说明

回答by javaPlease42

Make sure the context root is correct.

确保上下文根正确。

One can do this in the WebSphere Application Server administration console. Check IBM's Resolving the problem.

可以在 WebSphere Application Server 管理控制台中执行此操作。检查 IBM 的解决问题