RequestDispatcher.forward()到“/ WEB-INF”下的资源在WebSphere中不起作用 [英] RequestDispatcher.forward() to resource under "/WEB-INF" doesn't work in WebSphere

查看:196
本文介绍了RequestDispatcher.forward()到“/ WEB-INF”下的资源在WebSphere中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个servlet中,我调用 RequestDispatcher.forward()调用WEB-INF文件夹下的某个静态资源:

In one of my servlets, I invoke RequestDispatcher.forward() call to a static resource somewhere under WEB-INF folder:

request
    .getRequestDispatcher( "/WEB-INF/some/path/image.gif" )
        .forward( request, response );

导航到这个servlet在Tomcat,Jetty等下工作正常,但在WebSphere 7中不起作用。
我得到的错误(在浏览器和服务器日志中都是)

Navigating to this servlet works fine under Tomcat, Jetty et al., but does not work in WebSphere 7. The error I get (both in the browser and in the server logs) is

Error 403: SRVE0190E: File not found: /WEB-INF/some/path/image.gif

最初我认为WebSphere可能需要一些特定的配置来允许内部转发到WEB-INF下的资源,但我没有谷歌任何有用的东西。

Initially I assumed that WebSphere may need some specific configuration to allow internal forwarding to resources under WEB-INF, but I failed to google anything useful.

任何想法为什么会发生这种情况?

Any ideas why can this happen?

提前致谢!

推荐答案

看来应该设置 exposeWebInfOnDispatch 属性为 true ,以便为WebSphere中的servlet提供WEB-INF。我从 WebSphere论坛

It appears that one should set exposeWebInfOnDispatch property to true in order to make WEB-INF accessible for servlets in WebSphere. I got this answer from WebSphere forum.

在WebSphere 7管理控制台中,

In WebSphere 7 administration console,


  1. 转到服务器=>服务器类型=>WebSphere应用程序服务器左侧

  2. 选择

  3. 单击容器设置=>Web容器设置=>Web
    容器

  4. 转到右侧的自定义属性

  5. 添加新属性:

  1. Go to "Servers" => "Server Types" => "WebSphere application servers" on the left
  2. Choose proper server on the list on the main part of the page
  3. Click on "Container Settings" => "Web Container Settings" => "Web container"
  4. Go to "Custom properties" on the right
  5. Add new property:


  • 名称: exposeWebInfOnDispatch

  • 值: true

  • Name: exposeWebInfOnDispatch
  • Value: true

这篇关于RequestDispatcher.forward()到“/ WEB-INF”下的资源在WebSphere中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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