到目前为止,网上的大部分内容都是旧的,然后各位网友都在拼命的复制黏贴那些旧内容,导致新的东西几乎被覆盖掉,甚至误导了新手,把旧的配置当成新的来用。
Top 2. 把请求映射到Spring管理的MessageBroker,请求映射必须在3个地方被配置:
-
DispatcherServlet
mapping in web.xml(在web.xml配置DispatcherServlet
) -
HandlerMapping
in the Spring WebApplicationContext(配置SimpleUrlHandlerMapping
标签) - Channel definitions in the BlazeDS services-config.xml
<!-- Map all /messagbroker requests to the DispatcherServlet for handling --> <servlet-mapping> <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> <url-pattern>/messagebroker/*</url-pattern> </servlet-mapping>
使用这个标签<flex:message-broker />时,相当于默认调用
1 <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
2 <property name="mappings">
3 <value>
4 /*=_messageBroker
5 </value>
6 </property>
7 </bean>
8
9 <!-- Dispatches requests mapped to a MessageBroker -->
10 <bean class="org.springframework.flex.servlet.MessageBrokerHandlerAdapter"/>
注:When using the message-broker
config tag, a SimpleUrlHandlerMapping
is installed that by default maps all incoming DispatcherServlet
requests to the Spring-managed MessageBroker
using a /*
path pattern.
必须在BlazeDS 的services-config.xml文件中调整管道定义的映射。
1 <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
2 <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf"
3 class="flex.messaging.endpoints.AMFEndpoint"/>
4 <properties>
5 <polling-enabled>false</polling-enabled>
6 </properties>
7 </channel-definition>