开发者

Experiences with integrating spring 3 mvc with GWT?

Given: Spring 3.0 mvc has excellent REST support with one of the representation being JSON.

GWT simplifies development as UI is developed in java. But by default i开发者_开发技巧t uses RPC for client server interaction. But there is an option to use JSON.

Questions:

  1. Can you share experiences with using Spring 3.0 mvc with GWT ?

  2. What is the best approach to integrate these two frameworks?

  3. Is the default GWT's MVP architecture only for client side and does it work well with JSON?

Thanks


Can you share experiences with using Spring 3.0 mvc with GWT ?

Yes. We've successfully built a whole large application around GWT and Spring MVC (1500 source files, 6 months in development).

Spring was the key to the project's success. Only with Spring we were able to test individually some pieces of the application on the server side.

What is the best approach to marry these two frameworks?

Ignore the default Servlet used by GWT and instead create your own Spring controller to handle incoming GWT-RPC requests. This blog post was the key to integrating the two techs.

We also successfully integrated other components: Flash for animated charts and third-party Javascript components for other stuff. These communicate with the server through JSON. So you have two or more kinds of URLs:

  • the *.rpc urls are for GWT components and are served by the Spring controller for gwt
  • the *.json urls are for other components and are served by another Spring controller.

Also, in our case, we shunned configuration with annotations and instead preferred configuration with the good old Spring XML files. They make it much more clear what's going on. Except for the @Required annotation; it's great to find spring beans that should be connected but aren't.

Is the default GWT's MVP architecture only for client side and does it work well with JSON?

GWT's MVP architecture works best if you follow the guide lines. Use GWT-RPC communication as Google suggests.

You can still have JSON for other client-side components.


Try this solution: GWT and Spring MVC Integration

It uses 3 classes. Its very simple, declarative and clear.


It's stupid to mix Spring MVC and GWT. Also it's stupid to mix Spring MVC and JSF... It's stupid to mix 2 MVC (MVP) frameworks together. But you can use Spring DI and GWT for sure!


You may want to check out Spring Roo. It will help you get started quickly with Spring MVC, especially when dealing with RESTful URLs. It also provides a means to automatically set up GWT "scaffolding" (GWT code to interact with the Spring MVC backend). Hope it helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜