You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by we...@apache.org on 2009/05/29 22:22:11 UTC
svn commit: r780096 - in /struts/struts2/trunk/plugins/rest/src/main:
java/org/apache/struts2/rest/DefaultContentTypeHandlerManager.java
resources/struts-plugin.xml
Author: wesw
Date: Fri May 29 20:22:09 2009
New Revision: 780096
URL: http://svn.apache.org/viewvc?rev=780096&view=rev
Log:
WW-3128, thanks Brian!
Modified:
struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/DefaultContentTypeHandlerManager.java
struts/struts2/trunk/plugins/rest/src/main/resources/struts-plugin.xml
Modified: struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/DefaultContentTypeHandlerManager.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/DefaultContentTypeHandlerManager.java?rev=780096&r1=780095&r2=780096&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/DefaultContentTypeHandlerManager.java (original)
+++ struts/struts2/trunk/plugins/rest/src/main/java/org/apache/struts2/rest/DefaultContentTypeHandlerManager.java Fri May 29 20:22:09 2009
@@ -21,23 +21,26 @@
package org.apache.struts2.rest;
-import com.opensymphony.xwork2.ModelDriven;
-import com.opensymphony.xwork2.config.entities.ActionConfig;
-import com.opensymphony.xwork2.inject.Container;
-import com.opensymphony.xwork2.inject.Inject;
-import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.rest.handler.ContentTypeHandler;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import static javax.servlet.http.HttpServletResponse.SC_NOT_MODIFIED;
import static javax.servlet.http.HttpServletResponse.SC_OK;
+
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts2.ServletActionContext;
+import org.apache.struts2.rest.handler.ContentTypeHandler;
+
+import com.opensymphony.xwork2.ModelDriven;
+import com.opensymphony.xwork2.config.entities.ActionConfig;
+import com.opensymphony.xwork2.inject.Container;
+import com.opensymphony.xwork2.inject.Inject;
+
/**
* Manages {@link ContentTypeHandler} instances and uses them to
* process results
@@ -91,8 +94,12 @@
ContentTypeHandler handler = null;
String contentType = req.getContentType();
if (contentType != null) {
+ int index = contentType.indexOf(';');
+ if( index != -1)
+ contentType = contentType.substring(0,index).trim();
handler = handlersByContentType.get(contentType);
}
+
if (handler == null) {
String extension = findExtension(req.getRequestURI());
if (extension == null) {
Modified: struts/struts2/trunk/plugins/rest/src/main/resources/struts-plugin.xml
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/rest/src/main/resources/struts-plugin.xml?rev=780096&r1=780095&r2=780096&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/rest/src/main/resources/struts-plugin.xml (original)
+++ struts/struts2/trunk/plugins/rest/src/main/resources/struts-plugin.xml Fri May 29 20:22:09 2009
@@ -36,6 +36,7 @@
<bean type="org.apache.struts2.rest.handler.ContentTypeHandler" name="json" class="org.apache.struts2.rest.handler.JsonLibHandler" />
<bean type="org.apache.struts2.rest.handler.ContentTypeHandler" name="html" class="org.apache.struts2.rest.handler.HtmlHandler" />
<bean type="org.apache.struts2.rest.handler.ContentTypeHandler" name="x-www-form-urlencoded" class="org.apache.struts2.rest.handler.FormUrlEncodedHandler" />
+ <bean type="org.apache.struts2.rest.handler.ContentTypeHandler" name="multipart/form-data" class="org.apache.struts2.rest.handler.MultipartFormDataHandler" />
<constant name="struts.actionProxyFactory" value="rest" />
<constant name="struts.rest.defaultExtension" value="xhtml" />