Name

struts2-coc-plugin

Publisher

铁木箱子

License

Open Source (ASL2)

Version

0.1

Compatibility

Struts 2.1.8+

Homepage

http://code.google.com/p/struts2-coc-plugin/

Download

http://code.google.com/p/struts2-coc-plugin/downloads/list

{rate:title=Rating|theme=dynamic|key=5}

Overview

struts2-coc-plugin is struts2 plugin that based on Convention plugin.It do some coding optimization and coding convention,such as the mapper of URI and action method、file upload handle、json/text result response、validation input result redefined、action message populate after redirect and so on.The main purpose of struts2-coc-plugin is to help developer to develop with zero configuration but still guarantee the structure of project clearly and maintain easily!

struts2-coc-plugin是一款基于Convention插件的struts2插件,该插件主要在Convention插件基础上优化了部分处理流程,比如uri地址和action方法的映射、文件上传的处理、json/text文本输出的处理、校验和操作提示信息的处理等等。该插件的唯一目的就是真正的不进行一行配置,同时可以保持项目结构的清晰便于开发维护。INLINE

Struts2-coc-plugin is designed to help developer develop with zero configuration and still guarantee the structure of project clearly and maintain easily!

Features

struts2-coc-plugin is a plugin base on Convention plugin,it handle some thing to coding optimization and convention as following:

1.every action can service multiple request with simple uri

2.can redefine the input result in validation method with one method call

3.support define the different size and extensions of file when upload file through different url

4.support forward to view page directly when the method was not defined in the action

5.simple way to response the json and text to client through java annotations

6.support to populate the message that generated by action after the redirect

 

struts2-coc-plugin是一个基于Convention插件的struts2插件,该插件主要做了如下优化和约定开发:

1、每个action可以支持多个访问入口,使用普通的uri即可访问

2、在validate方法中可以通过调用父action的方法重新定义结果页面,默认的struts是返回到input界面

3、支持不同url地址文件上传时文件的大小、类型分别指定

4、支持当访问的url对应的action中没有指定的方法时可以直接定位到视图页面

5、json和文本输出的直接支持,简单的通过注解就可以实现方法的json和文本输出

6、action操作信息和错误信息处理,可以在redirect后取到并进行处理

Usage

1.Download latest artifact from http://code.google.com/p/struts2-coc-plugin/downloads/list

2.Download Convention plugin from https://cwiki.apache.org/S2PLUGINS/convention-plugin.html

3.Add these artifacts to your web application library dependencies or to your maven repository if you use maven manage your project

4.Configure the struts.properties and add following segments:

### +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ### + convertion 插件的配置 ### + 参看http://struts.apache.org/2.x/docs/convention-plugin.html ### +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ### 配置视图结果页面的路径,默认是 /WEB-INF/content struts.convention.result.path=/WEB-INF/content ### 指示是否将视图页面单独放置在以action命名的文件夹中,默认不是(true) #struts.convention.result.flatLayout=true ### 指定搜索Action的包路径中包含的名称,默认是action,actions,struts,struts2 ### 如下配置则表示所有包路径中包含 actions的包及其子包中进行搜索Action ### 搜索Action的规则是:Action接口的实现类和以Action作为名称结尾的类 struts.convention.package.locators=actions ### 指定包含了Action的jar文件的正则式,多个以逗号分隔 #struts.convention.action.includeJars= ### 指定当基于名称来查找Action时的类名的结尾部分,默认是Action #struts.convention.action.suffix=Action ### 指定默认的parent package,默认是convention-default struts.convention.default.parent.package=coc-default ### 指定action的名称、视图名称的分隔符,默认是- #struts.convention.action.name.separator=- ### 支持rest插件和coc插件 struts.convention.action.mapAllMatches=true ### +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ### + struts2-coc-plugin 插件的配置 ### +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ### action的默认方法,默认是index #struts.coc.defaultMethod=index ### 对于存在的处理器,是否限制访问后缀和方法注解必须一致才执行,默认false struts.coc.requestLimited=false ### 如果访问的方法不存在于action中是否将方法名称作为result返回,默认true #struts.coc.methodNameAsResult=true ### 是否处理action的message和error消息,默认true #struts.coc.handleMessage=true

5.Coding with struts2-coc-plugin:

public class TestAction extends CocActionSupport { /** * request URI is:/test/index */ public String index() { return "index"; } /** * request URI is:/test/list */ public String list() { return "list"; } }

Example

The whole documents and examples you can find here:http://code.google.com/p/struts2-coc-plugin/w/list

Or visit the author's blog to see more details:铁木箱子

Settings

The following settings can be customized.

Setting

Description

Default

Possible Values

struts.coc.defaultMethod

the default method of a action when request wihout method name
指定当一个请求直接映射到action时的默认访问方法

index

any

struts.coc.requestLimited

limit the request get json/text result from method must define the annotation
指定是否限制只有定义了json/text的注解才返回json/text数据

false

true|false

struts.coc.methodNameAsResult

dedicate the method name as result name when a request cann't match the method of the action
设置是否使用方法名称作为视图名称返回,当指定的URI没有找到对应action的方法时

true

true|false

struts.coc.handleMessage

dedicate whether handle the action message
指示是否处理action的信息,处理后可以在redirect后获取上次action设置的信息,通常用在像添加、编辑成功后的跳转处理中

true

true|false

Installation

This plugin can be installed by copying the plugin jar into your application's /WEB-INF/lib directory. No other files need to be copied or created.

Resources

Version History

Version

Date

Author

Notes

0.1

Aug 20, 2010

铁木箱子

first release

  • No labels