Spring MVC and Flex integration on BlazeDS?

What is the best way to integrate an existing spring-MVC-Project with flex. I am using spring -2.5 lib with annotations.

for example my list controller:

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);
}

I also have color.jsp that displays colors. Now I would like to combine flex as a UI layer. I only need to integrate spring -View with the RequestMappings shown above.

+3
source share
2 answers

Go get BlazeDS. Install it using the WAR file. You will also need a flash bank from Spring.

In the web.xml file, add the following:

<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>

Create the flex-servlet.xml file.

<?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>

Create the flexContext.xml file.

<?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" .

+1

Spring Flex, BlazeDS Java.

. Spring n Flex

0

Source: https://habr.com/ru/post/1715520/


All Articles