Problem solved
It turns out you need to configure the web.xml correctly and declare an appropriate view resolver.
For reference, I'm posting the solution here:
Here's my web.xml
Code:
<servlet>
<servlet-name>Multipart</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Multipart</servlet-name>
<url-pattern>/upload</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Multipart</servlet-name>
<url-pattern>/plain</url-pattern>
</servlet-mapping>
/upload - This is the entry point for our application
/plain - This is the view returned by the application
spring-integration.xml:
Code:
<int:channel id="INBOUND-HTTP" />
<int:channel id="REPLY"/>
<http:inbound-gateway request-channel="INBOUND-HTTP" name="/upload" supported-methods="POST, GET"
reply-channel="REPLY" view-name="plain" />
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver" p:order="1">
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
</list>
</property>
</bean>
Alternatively, you can declare the http inbound gateway as:
Code:
<bean id="httpInbound" class="org.springframework.integration.http.inbound.HttpRequestHandlingController" name="/upload">
<constructor-arg value="true" />
<property name="requestChannel" ref="INBOUND-HTTP" />
<property name="replyChannel" ref="REPLY" />
<property name="viewName" value="plain" />
<property name="supportedMethodNames">
<list>
<value>POST</value>
</list>
</property>
</bean>
Notice the view-name (or viewName depending if you're using the standard bean or namespace support) corresponds to the servlet mapping. And we've declared a ContentNegotiatingViewResolver and MappingJacksonJsonView which will convert the final response as JSON view.
If we want a JSP to be returned, we must declare an InternalResourceViewResolver
Code:
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/" p:suffix=".jsp"/>
And make sure you have a plain.jsp declared in the WEB-INF/jsp folder. The name must match the view-name and the servlet-mapping URL pattern.
I just wished that the Spring Integration reference was more transparent in explaining this feature. (By the way it took me 8 hours to figure this out starting from 8pm to 5am ...yep I didn't sleep until I was able to get this out).
When I have the extra time, I will be uploading a tutorial about this to my blog at http://krams915.blogspot.com