Struts 1.1与Servlet 2.4的资源路径问题

现象:

应用程序发布在WebSphere Application Server 5.x上可以正常运行,但当这个应用程序发布到WebSphere Application Server 6.0上时,出现下面的错误:
ActionServlet E TRAS0014I:
下列异常已记录 java.net.MalformedURLException: SRVE0238E: 资源路径应该以斜杠开头
at com.ibm.ws.webcontainer.webapp.WebApp.
getResource(WebApp.java:1915)
at com.ibm.ws.webcontainer.facade.
ServletContextFacade.getResource
(ServletContextFacade.java:100)
at org.apache.struts.action.ActionServlet.
parseModuleConfigFile(ActionServlet.java:1002)
at org.apache.struts.action.ActionServlet.
initModuleConfig(ActionServlet.java:955)
at org.apache.struts.action.ActionServlet.
init(ActionServlet.java:470)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at com.ibm.ws.webcontainer.servlet.
ServletWrapper.init(ServletWrapper.java:262)
at com.ibm.ws.webcontainer.servlet.
ServletWrapper.initialize(ServletWrapper.java:1319)
at com.ibm.wsspi.webcontainer.extension.
WebExtensionProcessor.
createServletWrapper(WebExtensionProcessor.java:84)
at com.ibm.ws.webcontainer.webapp.WebApp.
getServletWrapper(WebApp.java:745)
at com.ibm.ws.webcontainer.webapp.WebApp.
initializeTargetMappings(WebApp.java:493)
... ...

WebExtensionP W Servlet action is currently
unavailable: Parsing error processing resource path

WebExtensionP E SRVE0026E: Servlet 错误]-
javax.servlet.UnavailableException:
Parsing error processing resource path
at org.apache.struts.action.ActionServlet.
handleConfigException(ActionServlet.java:1035)
at org.apache.struts.action.ActionServlet.
parseModuleConfigFile(ActionServlet.java:1010)
at org.apache.struts.action.ActionServlet.
initModuleConfig(ActionServlet.java:955)

at org.apache.struts.action.ActionServlet.
init(ActionServlet.java:470)

原因:这是由于在 Struts 1.1 中,获得资源路径时,前面不带斜线( / ),但在Servlet 2.4规范中,要求在获得一个资源路径时,路径必须是相对与当前上下文根并以斜线( / )开头。
WebSphere Application Server 5.x中允许资源的URL不是以斜线( / )开头,但在WebSphere Application Server 6.0中,使用的是Servlet 2.4的规范,为了保持兼容性,需要在web容器中添加一个prependSlashToResource的属性来避免错误。

解决办法:

具体步骤:
登陆 WebSphere 管理控制台,进入 服务器->对应的服务器名称 -> WEB容器 -> 其他属性 ->添加
添加下面的属性:
名称:prependSlashToResource
值:true

然后保存配置,重新启动WebSphere Application Server

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值