Struts2 Convention Plugin 学习
来源:互联网 发布:3d游戏编程入门教程 编辑:程序博客网 时间:2024/05/24 05:27
从struts2.1版本开始,Convention Plugin作为替换替换Codebehind Plugin来实现Struts2的零配置。
Convention使用以下方法来搜索类路径,首先,Convention会从根package中寻找包名含有struts, struts2, action or actions 的任意packages。下一部,Convention从前一步找到的package以及其子package中寻找
下面为Convention寻找的类
Classes
com.example.actions.MainAction
com.example.actions.products.Display (implements com.opensymphony.xwork2.Action)
com.example.struts.company.details.ShowCompanyDetailsAction
每一个被Convention找到action都会对应一个明确的URL地址,URL以package的名字以及Action类名为基础。
首先Convention从根package以及类所在的package名来确定对应的URL中的路径(namespace),以下就是根据package确定的URL namespace
Namespaces
com.example.actions.MainAction -> /
com.example.actions.products.Display -> /products
com.example.struts.company.details.ShowCompanyDetailsAction -> /company/details
接下来Convention需要确定URL的具体资源部分。第一步取消类名中的Action,并以”-”来分割类名的其他部分,且将每个分部的首字母转为小写。如下所示
Full URLs
com.example.actions.MainAction -> /main
com.example.actions.products.Display -> /products/display
com.example.struts.company.details.ShowCompanyDetailsAction -> /company/details/show-company-details
你也可以通过配置struts.convention.exclude.packages 来告诉Convention忽略某些包,也可以设置struts.convention.package.locators 用来更改Convention默认的根packages,最后你还可以设置 struts.convention.action.packages. 来让Convention只搜索特定package下的Action
结果页面的类型会自动匹配文件,支持的渲染页面的格式为:jsp.ftl,vm,html,htm.下面是actiong和结果模版的映射关系:
URL
Result
File that could match
Result Type
/hello
success
/WEB-INF/content/hello.jsp
Dispatcher
/hello
success
/WEB-INF/content/hello-success.htm
Dispatcher
/hello
success
/WEB-INF/content/hello.ftl
FreeMarker
/hello-world
input
/WEB-INF/content/hello-world-input.vm
Velocity
/test1/test2/hello
error
/WEB-INF/content/test/test2/hello-error.html
Dispatcher
- Struts2 Convention Plugin 学习
- Struts2 convention plugin 学习资料
- struts2: config-browser-plugin 与 convention-plugin 学习
- Struts2 Convention Plugin
- struts2-Convention+Plugin 中文
- struts2-convention-plugin插件
- struts2 convention plugin翻译
- Struts2 convention plugin (1)
- Struts2 convention plugin
- Struts2 convention plugin
- Struts2--convention-plugin
- struts2 convention plugin
- struts2 convention plugin 学习笔记零配置学习笔记本 huitoukest
- 转struts2-convention-plugin插件
- struts2 Convention Plugin Configuration reference
- Struts2 convention-plugin 使用笔记
- Struts2 convention-plugin 使用笔记
- Struts2 Convention Plugin中文文档
- Delphi学习笔记
- 原来爱情是如此温暖
- 【转】GTK+主循环(main loop)的工作原理
- 『转帖』对360安全卫士自我保护的简单研究
- 明晰C++内存分配的五种方法的区别
- Struts2 Convention Plugin 学习
- solaris crontab
- JS with的使用
- 我为啥选择QQ和360?
- 控制C++的内存分配
- Linux 内核梦
- outpost pro 7.0注册码
- 利用第三方浏览器漏洞钓鱼
- 解决QQ和360软件冲突的方法 让QQ和360软件能同时运行