3

这是将现有 spring-MVC-Project 与 flex 集成的最佳方式。我正在使用带有注释的 Spring-2.5 lib。

例如我的列表控制器:

package xxx.xxx.controller;

@Controller
public class ListController {

 @Autowired
 private ColorHome colorHome;

@RequestMapping("/admin/colors.do")
public ModelMap colorsHandler() {
    Collection<Object> colors = this.colorHome
            .findColors();
    return new ModelMap(colors);
}

我还有一个显示颜色的colors.jsp。现在我想将 flex 集成为 UI 层。我只需要将 Spring-View 与上面显示的 RequestMappings 集成。

4

2 回答 2

1

去获取 BlazeDS。使用 WAR 文件安装它。您还需要 Spring 的 flex jar。

在您的 web.xml 文件中,添加以下内容:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/flexContext.xml
    </param-value>
</context-param>
<servlet>
    <servlet-name>flex</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>flex</servlet-name>
    <url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>

创建一个 flex-servlet.xml 文件。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:flex="http://www.springframework.org/schema/flex"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
</beans>

创建一个 flexContext.xml 文件。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:flex="http://www.springframework.org/schema/flex"
    ...
">
    <flex:message-broker />

    <flex:remoting-destination destination-id="flexService" ref="beanFromApplicationContext" />

</beans>

这应该足以让您获得远程端点。

在 Flex 中,创建一个 remoteObject 并将其指定为“flexService”或您在 to 上设置的任何目标 ID。

于 2009-08-20T16:23:26.313 回答
0

Spring 有一个与 Flex、BlazeDS 和 Java 集成的项目。

这可能会帮助你。Spring n Flex 集成

于 2009-08-24T06:49:20.927 回答