« Return to Thread: DWR 2 and Spring 2

Re: DWR 2 and Spring 2

by Lexius :: Rate this Message:

Reply to Author | View in Thread


Brendan Grainger-2 wrote:
Hi,

This is actually a bit of a gotcha I think. Anyway, by default Springs
SimpleUrlHandlerMapping sets alwaysUseFullPath to false and in our
web.xmlwe've mapped /dwr/* to the spring dispatcher servlet (someone
please correct
me if I'm wrong). So the pattern that gets passed to SimpleUrlHandlerMapping
by spring is the bit _after_ /dwr. By making the dwrController match
everything request that falls through the mappings you've defined you're
catching it but you might not want that in general eh?

Anyway, if you set alwaysUseFullPath to false SimpleUrlHandlerMapping you
can do something like this:

    <bean id="urlHandlerMapping" class="
org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="alwaysUseFullPath" value="true"></property>
        <property name="mappings">
            <props>
...
                <prop key="/dwr/**/*">dwrController</prop>
          </props>
etc

The way I've set it up in spring is to have two SimpleUrlHandlingMapping
instances declared. One for regular spring controllers and another for dwr
like so:

    <bean id="urlHandlerMapping" class="
org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
            <props>
                <prop key="/blog/captchaImage.do">commons.captchaController
</prop>
                <prop key="/blog/categoryList.do">
weblog.categoriesListController</prop>
...
            </props>
        </property>
    </bean>


    <bean id="dwrHandlerMappings" class="
org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="order" value="1" />
        <property name="alwaysUseFullPath" value="true"></property>
        <property name="mappings">
            <props>
                <prop key="/dwr/**/*">dwrController</prop>
            </props>
        </property>
    </bean>

Let me know if that helps.

Brendan





On 12/16/06, Lexius <lexius.info@gmail.com> wrote:
>
>
>
>
> Brendan Grainger-2 wrote:
> >
> > Sure, I'm assuming you have spring MVC working.
> >
> > I have this in my springDispatcher-servlet.xml (or something similar).
> > ...
> >
>
> Thanks.
> Now it work for me. The problem was in url mapping:
>
> <bean id="urlMapping"
> class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
>         ...
>         <property name="mappings">
>             <props>
>                 <prop key="/test.html">testController</prop>
>                 <prop key="/flowController.html">flowController</prop>
>                 <prop key="/*">dwrController</prop>
>             </props>
>         </property>
>
>     </bean>
>
> But I don't know how to map dwrController to one url. I get it working
> only
> for /* mapping.
> Can you help me?
>
> (Sorry for my English, I am from Ukraine)
> --
> View this message in context:
> http://www.nabble.com/DWR-2-and-Spring-2-tf2832281.html#a7908369
> Sent from the DWR - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@dwr.dev.java.net
> For additional commands, e-mail: users-help@dwr.dev.java.net
>
>
Thanks! Now all working good!

Eugeniy.

 « Return to Thread: DWR 2 and Spring 2