使用struts2中的codebehind插件
来源:互联网 发布:sql developer的set 编辑:程序博客网 时间:2024/05/18 20:51
转载:http://www.cnblogs.com/modou/articles/1301597.html
codebehind plugin是一个可以简化struts2配置的插件,虽然不能实现完全意义上的codebehind,至少已经做的不错了,期待新版本:-D
使用步骤:
1.确保你的应用已经可以使用struts2
2.添加struts2-codebehind-plugin-2.0.11.2.jar包到应用中
3.struts.xml中添加配置:<constant name="struts.codebehind.pathPrefix" value="/jsp/" /> 这里的value值填写jsp页面的根路径
然后就可以使用了,在不使用codebehind插件的时候,一般是这么写的:
<action name="userlist" class="userListAction"> <result>/jsp/userlist.jsp</result></action>
使用codebehind插件的话,可以这么写:
<action name="userlist" class="userAction" />
result可以省略了,当然这里有一个约定,返回页面的路径为struts.codebehind.pathPrefix + package namespace + action name + action returntype + .jsp
我这里的环境:
struts.codebehind.pathPrefix = /jsp/
package namespace = /
action name = userlist
action returntype = 为success时,值为空,为其他时,值为"-" + return type
所以返回的页面地址就为 /jsp/userlist.jsp
如果return type为input,地址就为 /jsp/userlist-input.jsp
配合表达式的使用,可以基本实现零配置:
<action name="*" class="{1}Action" />
这样写不仅可以简化配置,而且可以达到规范文件布局的目的。如果有特殊的需要,也完全可以与手写配置文件相结合,用起来已经很方便了。
- 使用struts2中的codebehind插件
- 使用struts2中的codebehind插件
- struts2中的dojo插件使用
- struts2.3.1 使用codebehind插件实现零配置时struts.xml中必须加入一个<constant name="struts.enable.DynamicMethodInvocati
- asp.net中的codebehind
- Struts2中的json插件
- Struts2零配置 Zero Config+CodeBehind
- Struts2零配置中的config-browser插件的使用问题
- struts2 Convention 插件使用
- Struts2使用 -- Convention插件
- ASP.NET中的CodeBehind技术(4)
- ASP.NET中的CodeBehind技术(3)
- ASP.NET中的CodeBehind技术(2)
- ASP.NET中的CodeBehind技术(1)
- Struts2使用26 -- Convention插件
- Struts2 使用26 -- Convention插件
- Struts2 Convention插件的使用
- Struts2 json插件的使用
- Styling Microsoft’s WPF datagrid
- struts2配置文件
- 程序员
- 身在计院 路在何方 part-1
- Fedora的一些基本设置
- 使用struts2中的codebehind插件
- 嵌入式系统文件系统比较 jffs2, yaffs, cramfs, romfs, ramdisk, ramfs/tmpfs
- ASCII码表
- Mapreduce作业的工作原理
- Barbecue 条形码
- 用 cmake 构建Qt工程(对比qmake进行学习)
- SPI与SCI的一些比较
- PHPExcel的exception 'Exception' with message 'The filename is not recognised as an OLE file问题解决
- 数的分解