Clean DWR spring integration
To integrate DWR to spring framework, the first thing to do is to configure web.xml. Add the following text to your web.xml.
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
Then you have to tell spring to delegate the dwr calls to the dwr controller which is normally configured in spring-servlet.xml like below.
<dwr:controller id="dwrController" debug="true" />
Now you need to configure the spring url mappings, and there comes a small problem : you can’t simplely map all URLs that matches /dwr/* pattern to the DWR Controller, because in the default configuration spring sees these URLs without the /dwr prefix. So, for example /dwr/engine.js will basically be treated as engine.js.
Bram Smeets found a perfect solution for this problem. The trick is to define a new url mapper that will handle just DWR URLs.
<bean id="dwrUrlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="alwaysUseFullPath" value="true" />
<property name="mappings">
<map>
<entry key="/dwr/**/*" value-ref="dwrController"></entry>
</map>
</property>
</bean>
No comments yet
Jump to comment form | comments rss [?] | trackback uri [?]