让Struts2 + Spring2在Resin3.0.x下正常运行

 先介绍如何让Spring2.0在Resin下正常运行。
因为Resin缺省没有用xerces解析xml,所以resin无法解析Spring2.0的配置文件。
具体做法:1. 拷贝xercesImpl.jar,xml-apis.jar,如果用到xslt,还需要拷贝xalan.jar;
2. 将下面几行加入到resin.conf中:
<system-property javax.xml.parsers.DocumentBuilderFactory='org.apache.xerces.jaxp.DocumentBuilderFactoryImpl'/>
<system-property javax.xml.parsers.SAXParserFactory='org.apache.xerces.jaxp.SAXParserFactoryImpl'/>
如果用到xslt,还要加入一行:<system-property javax.xml.transform.TransformerFactory='org.apache.xalan.processor.TransformerFactoryImpl>
 
因为struts2的服务方式为filter方式,而Resin的mod_caucho插件正常情况下仅会对Servlet,Jsp服务,不会对Filter过滤的网址服务,这给struts2在Resin上使用带来一些问题。这可使用"Special servlet-mappings",详细情况可以参考 http://www.caucho.com/resin-3.0/install/plugin-dispatch.xtp
也就是说,对于一些特殊的url,可以使用plugin_match来让resin来服务,而plugin_ignore的作用正好相反。
在这里,我们需要plugin_match,为了避免打乱正常的配置,我们使用和web.xml文件相同作用的resin-web.xml来设置相应的url,这样设置仅对resin有效,不影响其他server,还是不错的。
最后的resin-web.xml是这样的:
<web-app xmlns=" http://caucho.com/ns/resin">
 <servlet-mapping url-pattern='/struts/*' servlet-name='plugin_match'/>
 <servlet-mapping url-pattern='/other/*' servlet-name='plugin_match'/>
 <servlet-mapping url-pattern='*.action' servlet-name='plugin_match'/>
 <servlet-mapping url-pattern='*.html' servlet-name='plugin_match'/>
 <servlet-mapping url-pattern='*.do' servlet-name='plugin_match'/>
 <servlet-mapping url-pattern='/dwr/*' servlet-name='plugin_match'/>             
</web-app>
这样struts2的action就可以正常工作了。
 
另外,如果url后面自动跟上jsessionid的话,resin会反应404找不到网页的错误。在host里配置里加上<session-config enable-cookies='true' enable-url-rewriting='false'/>可避免些问题。
摘自:
http://mtiger2k.blog.51cto.com
90203.html

坏男孩 2006-12-27 08:19 发表评论
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值