2012-11-20 34 views
2

我已经下载Spring Webflow来源和我想添加REST通道(从数据库显示图像)到示例的jsf-booking样本。这个频道在我的Spring-MVC示例应用程序中没有任何问题。如何将REST通道添加到Spring Webflow应用程序?

不过,我有一个映射问题,因为在给定的地址JSF处理程序与该display.xhtml文件不存在(剩下的侦听器应该处理该请求)错误信息响应。

我这是怎么注册的处理程序:

@Controller 
@RequestMapping(value="/image") 
public class ImageChannelImpl implements ImageChannel { 

    @RequestMapping(value="/display.png", method=RequestMethod.GET) 
    public void display(HttpServletResponse response) throws IOException { 
(...) 
     response.setContentType("image/png"); 
     ImageIO.write(img, "PNG", response.getOutputStream()); 
     response.getOutputStream().flush();  
     log.debug("display finished"); 
    } 

}

我复制的处理程序映射;

<bean 

    class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> 
    <property name="messageConverters"> 
     <util:list id="beanList"> 
      <ref bean="stringHttpMessageConverter" /> 
      <ref bean="byteArrayHttpMessageConverter" /> 
     </util:list> 
    </property> 
</bean> 

<bean id="stringHttpMessageConverter" 
    class="org.springframework.http.converter.StringHttpMessageConverter" /> 

<bean id="byteArrayHttpMessageConverter" 
    class="org.springframework.http.converter.ByteArrayHttpMessageConverter" /> 

DispatcherServlet应用监听/春/ *请求:

<!-- The front controller of this Spring Web application, responsible for handling all application requests --> 
<servlet> 
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <init-param> 
     <param-name>contextConfigLocation</param-name> 
     <param-value></param-value> 
    </init-param> 
    <load-on-startup>2</load-on-startup> 
</servlet> 

<!-- Map all /spring requests to the Dispatcher Servlet for handling --> 
<servlet-mapping> 
    <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> 
    <url-pattern>/spring/*</url-pattern> 
</servlet-mapping> 

所以,我预计,该图像将可在地址/spring/image/display.png,但REST处理程序没有接受该请求,也没有处理/image/display.png。

那么,什么必须在配置进行更改,以便休息信道可以注册?我试图谷歌任何示例或文档,如何配置Spring WebFlow和Spring MVC频道,但我没有找到任何东西。

回答

0

你应该定义的默认处理程序“为您FlowHandlerMapping:

<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"> 
    <property name="flowRegistry" ref="flowRegistry"/> 
    <property name="order" value="0"/> 
    <!--If no flow match, map path to a view to render; e.g. the "/intro" path would map to the view named "intro" --> 
    <property name="defaultHandler" ref="requestMappingHandlerMapping"/> 
</bean> 

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" id="requestMappingHandlerMapping"> 
    <property name="order" value="1"/> 
</bean> 

您可以替换取决于你的Spring MVC版本AnnotationMethodHandlerAdapter上RequestMappingHandlerMapping(RequestMappingHandlerMapping是在最后SMVC的首选方式发行版)

相关问题