---
title: "又发现struts2 rest plugin的一个问题"
author: "rustlingwind"
date: "2010-03-28T20:38:50Z"
tags: []
categories: ["企业架构"]
slug: "struts2-rest-plugin"
draft: false
lastmod: "2010-03-28T22:08:14Z"
id: 626697
url: "https://rustlingwind.iteye.com/blog/626697"
---

又发现rest plugin的一个问题：

DefaultContentTypeHandlerManager:
// Don't return any content for PUT, DELETE, and POST where there are no errors
        if (!statusNotOk && !"get".equalsIgnoreCase(req.getMethod())) {
            target = null;
        }
导致经过正确处理的put和delete请求，无法返回xml/json内容（成功提示等）
间接导致jquery ajax 调用失败（response=null）？

如果可能，如何重写该类（只需将这段屏蔽掉即可）？
http://mail-archives.apache.org/mod_mbox/struts-user/201002.mbox/%3C3d5bf9841002231520u56375851rd0a0ac4f80b6c7b3@mail.gmail.com%3E
http://mail-archives.apache.org/mod_mbox/struts-user/201002.mbox/thread?2
但这个mail仍然没有人回答。。


/////////////////////////////////////////
竟然也有人在这篇文章的末尾弱弱的提问这个问题：
http://raibledesigns.com/rd/entry/go_light_with_apache_struts

终于发现这个问题的确是个bug，在apache的bug列表里面有：
http://issues.apache.org/jira/browse/WW-3303

/////////////////////////////////////////
项目比较着急，没时间继续找办法了。直接修改struts2-rest-plugin 的源代码解决之。
好在只是修改一个插件的代码，并且strut2全部使用maven作为构建工具，直接在源代码中屏蔽掉这段话，然后在rest的根目录mvn clean install，我的程序便能成功运行了，其实这么做也不赖，呵呵。。。

但这样做的前提是我得把所作的修改记下来，不然升级strut2的时候又坏了，除非这个问题在下一个版本中已经更正。还是在这里先提醒一下自己。。。