Spring Form Controller with DWR

2019-05-10 12:16发布

问题:

I am using spring and DWR combination,When i do ajax request from DWR.I want to access entire form values bind to the bean in my DAO layer.

I didn't find any examples for Spring form controller with DWR.

Any suggestions or help appreciated.

Thanks in Advance.

Regards,

Raj

回答1:

Considering your problem is how to create Spring-DWR integration, so that you can simulate Spring controller calls from Java, try it like this:

Your Spring XML config:

<bean id="myController" class="pkg.MyController">

    <property name="service1" ref="service1Bean"/>
    <property name="service2" ref="service2Bean"/>

    <dwr:remote javascript="MyControllerInJavascript">
        <dwr:include method="method1"/>
        <dwr:include method="method2"/>
    </dwr:remote>

</bean>

Your controller:

package pkg;

public class MyController {

    public SomeObject method1(String argument1, Long argument2) {
        ...
    }

    public OtherObject method2(YetAnotherObject argument1) {
        ...
    }

}

In your Javascript:

<script type="text/javascript"
        src="/your_dwr_path/interface/MyControllerInJavascript.js"/>

MyControllerInJavacript.method1('argument',123,callbackMethod);

Further integration steps you can find at the docs.