读书人

Struts 与 dojo 调整研究 (一)

发布时间: 2012-09-02 21:00:34 作者: rapoo

Struts 与 dojo 整合研究 (一)

?

Struts 与 dojo 整合研究

1,???????Struts的dojo标签

Struts框架有一些Ajax的插件,例如:

????????Ajax Parts - The AjaxParts Taglib (APT) is a component ofthe Java Web Parts (JWP) project (http://javawebparts.sourceforge.net) that allows for100% declarative?

?????????????????????????? (read: no Javascript coding required!) AJAX functionalitywithin a Java-based webapp.

????????Dojo - The Ajax Tags Dojo Plugin was represented as a theme for Struts 2.0.For Struts 2.1, the Dojo tags are bundled as a plugin.

????????YUI The Yahoo User Interface (YUI) Plugin has only a fewtags are available so far, but the YUI tags tend to be easier to use than theDojo versions.

????????jQuery - The jQuery Plugin provide ajaxfunctionality and UI Widgets an JavaScript Grid based on the jQuery javascriptframework..

?????????????? 其中Ajax Tags Dojo Plugin在struts2.1中已经被废除了,主要是由于dojo之前的版本不稳定,最新的dojo插件(struts2-dojo-plugin-2.2.3.jar)也只支持dojo0.4

?????????????? 版本的核心,一共11个标签,如果不用struts的dojo标签就设计到数据转换的问题,下面第2点说明。

?

???????? 1)??json格式的数据比xml在web2.0的应用中性能要好,主要是因为javascript对json的解析和序列化比xml要方便,因此考虑用json做前后端的数据传输格

? ? ? ? ? ? ? ? ? ? ? 式。另外由于后端处理request的时候和是否是Ajax请求并无关系,主要是在后台返回response的时候,前台的script对数据格式有一定的要求,所以本文主要

????????????????????? 分析后台在应用Struts之后返回json数据给前台的处理方法。?

?

? ? ?It provides a"json" result type that serializes beans into JSON!

No interceptor is provided by this plugin, only the json result type is provided.

  • more powerful include/exclude patterns are supported(thanks to the features of flexjson)

    存在的问题:

    1,? 反序列化未实现,即前台dojo直接发json的数据格式的请求,让jsonplugin自动序列化成java对象的工作。但可用struts2的域模型驱动来做,比较好做,jsonplugin插件并不是最佳的反序列化的选择!

    2,? 调研jsonRPC的应用(之后会上传,期待你的关注哦^_^)

    3, 本文源码文件也许没有组织好,文章也写的比较粗放,欢迎大家指正!

  • 读书人网 >软件架构设计

    热点推荐