java痛苦学习之路[四]---关于struts2-convention-plugin使用
一、struts2-convention-plugin配置文件具体解释
<constant name="struts.convention.actionConfigBuilder" value="convention"/>
<constant name="struts.convention.actionNameBuilder" value="convention"/>
<constant name="struts.convention.resultMapBuilder" value="convention"/>
<constant name="struts.convention.interceptorMapBuilder" value="convention"/>
<constant name="struts.convention.conventionsService" value="convention"/>
<constant name="struts.convention.result.path" value="/WEB-INF/content/"/>
设置Convention插件定位视图资源的根路径。默认值为/WEB-INF/content/
<constant name="struts.convention.result.flatLayout" value="true"/>
假设设置为false,则能够将视图页面放置Action相应的文件夹下(无需放入/WEB-INF/content/下)
<constant name="struts.convention.action.suffix" value="Action"/>
Convention搜索Action类的类名后缀。默认值为Action
<constant name="struts.convention.action.disableScanning" value="false"/>
是否通过禁止包扫描Action。默认值是false
<constant name="struts.convention.action.mapAllMatches" value="false"/>
设置即使没有@Action凝视。依旧创建Action映射。默认值是false
<constant name="struts.convention.action.checkImplementsAction" value="true"/>
设置是否实现了Action接口的类映射成Action。默认值是ture
<constant name="struts.convention.default.parent.package" value="convention-default"/>
设置Convention映射的Action所在包的默认父包。
默认值是convention-default
<constant name="struts.convention.action.name.lowercase" value="true"/>
设置映射Action时,是否将Action的name属性值转为全部字母小写。默认值是true
<constant name="struts.convention.action.name.separator" value="-"/>
设置映射Action时指定name属性值个单词之间的分隔符。默认值是中画线
<constant name="struts.convention.package.locators" value="action,actions,struts,struts2"/>
Convention插件使用该常量指定包作为搜索Action的根包默认值是action,actions,struts,strtus2
<constant name="struts.convention.package.locators.disable" value="false"/>
指定禁止从Action的根包里所搜Action。默认值是false
<constant name="struts.convention.package.locators.basePackage" value=""/>
假设指定了该常量,Convention仅仅会从以该常量值開始的包中搜索Action类。
<constant name="struts.convention.exclude.packages" value="org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.*"/>
指定排除在搜索Action之外的包。默认值为org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.*
<constant name="struts.convention.relative.result.types" value="dispatcher,velocity,freemarker"/>
指定Convention映射Result时默认支持的结果类型。默认值是dispatcher,velocity,freemarker
<constant name="struts.convention.redirect.to.slash" value="true"/>
设置是否重定向到斜线(/)。比如用户请求/foo,但/foo不存在时。假设设置该常量为则可重定向到/foo/。默认值是true
<constant name="struts.convention.action.alwaysMapExecute" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="true"/>
<!-- <constant name="struts.convention.action.includeJars" /> -->
<constant name="struts.convention.action.fileProtocols" value="jar" />
<constant name="struts.convention.classes.reload" value="false" />
<constant name="struts.convention.exclude.parentClassLoader" value="true" />
二、project实例
(一) struts2-convention-plugin依赖包,放到projectlib文件夹下:
(二) web.xml 配置
(三) strut2.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.devMode" value="true"/>
<!-- 开发模式 -->
<constant name="struts.configuration.xml.reload" value="true" />
<!-- 配置文件又一次载入 -->
<constant name="struts.i18n.encoding" value="UTF-8"/>
<!-- Web运用编码 -->
<constant name="struts.convention.result.path" value="/" />
<!-- 搜索视图资源的路径 -->
<constant name="struts.convention.action.name.separator" value="_" /> <!-- Action类名分隔符 -->
<constant name="struts.convention.classes.reload" value="true" /> <!-- convention类重载入 -->
<constant name="struts.convention.action.suffix" value="Action" /> <!-- Action后缀名 -->
<constant name="struts.action.extension" value="action,do,html,htm,php,aspx" /> <!-- Action扩展名 -->
<constant name="struts.convention.package.locators" value="action,actions" /> <!-- 搜索Action资源的包路径 -->
<!-- 启用动态方法调用 true:actionName!Method.action这样的形式好用。false:actionName!Method不好用-->
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<!-- 结果类型 -->
<constant name="struts.convention.relative.result.types" value="dispatcher,freemarker"/>
<!-- 基于什么包 -->
<constant name="struts.convention.package.locators.basePackage" value="net.yeah.fancydeepin.action"/>
<!-- 名称首字母小写 -->
<constant name="struts.convention.action.name.lowercase" value="true"/>
<!-- 检查是否实现action -->
<package name="default" extends="struts-default">
<interceptors>
<interceptor-stack name="defaultStack">
<interceptor-ref name="exception" />
<interceptor-ref name="servletConfig" />
<interceptor-ref name="actionMappingParams" />
<interceptor-ref name="staticParams" />
<interceptor-ref name="params" />
</interceptor-stack>
</interceptors>
</package>
</struts>
(四) 在src文件夹下新建DemoAction类,配置例如以下图所看到的:
(五) 在projectwebRoot文件夹下,新增index.jsp 和error.jsp,index.jsp 文件内容里面加
<a href="./demo!error.action">生成错误</a>
java痛苦学习之路[四]---关于struts2-convention-plugin使用的更多相关文章
- java痛苦学习之路[十]--日常问题汇总
FIddler2 1.FIddler2 request请求的參数出现中文乱码问题时,须要进行一下设置: 打开注冊表编辑器,找到HKCU\Software\Microsoft\Fiddler 2\,在 ...
- java痛苦学习之路[十二]JSON+ajax+Servlet JSON数据转换和传递
1.首先client须要引入 jquery-1.11.1.js 2.其次javawebproject里面须要引入jar包 [commons-beanutils-1.8.0.jar.commons-c ...
- Java NIO 学习笔记(四)----文件通道和网络通道
目录: Java NIO 学习笔记(一)----概述,Channel/Buffer Java NIO 学习笔记(二)----聚集和分散,通道到通道 Java NIO 学习笔记(三)----Select ...
- Struts2 Convention Plugin ( struts2 零配置 )
Struts2 Convention Plugin ( struts2 零配置 ) convention-plugin 可以用来实现 struts2 的零配置.零配置的意思并不是说没有配置,而是通过约 ...
- java的学习之路01
[原创 - 尚学堂科技 - 马士兵老师] JAVA自学之路 一:学会选择 [转载请注明出处:http://www.bjsxt.com/zixue/zixuezhilu_1.html] 为了就业,不少同 ...
- Redis——学习之路四(初识主从配置)
首先我们配置一台master服务器,两台slave服务器.master服务器配置就是默认配置 端口为6379,添加就一个密码CeshiPassword,然后启动master服务器. 两台slave服务 ...
- Java的学习之路
记事本 EditPlus eclipse Java的学习软件,已经系统性学习Java有一段时间了,接下来我想讲一下我在Java学习用到的软件. 1.第一个软件:记事本 记事本是Java学习中最基础的编 ...
- Java开发学习(二十四)----SpringMVC设置请求映射路径
一.环境准备 创建一个Web的Maven项目 参考Java开发学习(二十三)----SpringMVC入门案例.工作流程解析及设置bean加载控制中环境准备 pom.xml添加Spring依赖 < ...
- [原创]java WEB学习笔记55:Struts2学习之路---详解struts2 中 Action,如何访问web 资源,解耦方式(使用 ActionContext,实现 XxxAware 接口),耦合方式(通过ServletActionContext,通过实现 ServletRequestAware, ServletContextAware 等接口的方式)
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
随机推荐
- B - Soldier and Bananas
Problem description A soldier wants to buy w bananas in the shop. He has to pay k dollars for the fi ...
- 第二次作业&熟悉使用工具
GIT地址 我的地址 GIT用户名 995020892w 学号后五位 81105 博客地址 我的博客 作业链接 第二次作业 一.环境配置过程 安装vs2017 因为以前学习C#相关 ...
- 【MFC】基于opencv的趣味相机
为了参加学校的科技节,故用mfc随手制作了一个名为<趣味相机>的小程序: 其中对图形图像处理运用到了opencv. 效果图 这界面逼格低了点╭(╯^╰)╮ 有兴趣的朋友可以在此下载尝试:h ...
- hdu3861 The King’s Problem 强连通缩点+DAG最小路径覆盖
对多校赛的题目,我深感无力.题目看不懂,英语是能懂的,题目具体的要求以及需要怎么做没有头绪.样例怎么来的都不明白.好吧,看题解吧. http://www.cnblogs.com/kane0526/ar ...
- ACM_____不再爱你……
不再爱你…… 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 现在有一个圆柱形水杯,里面装满了水,在它的底部有一个小洞,通过一些简单的物理知识我们可以知道: 1.由于重力 ...
- **PCL:嵌入VTK/QT显示(Code^_^)
中国人真是太不知道分享了,看看这个老外的博客,启发性链接. http://www.pcl-users.org/ 1. 这个是可用的源代码: 原文:I saw a thread with links t ...
- PhotoZoom官方这举动,大写服!
上上周,PhotoZoom Classic7首次特惠活动大家都知道哈~~ 厂商福利限量30套,仅售99RMB,活动一经上线,半天时间一售而光,这说明不是大家不需要这个智能小软件啊,而是,可能,大概,也 ...
- Javaee 方法的格式和注意事项
1.构造方法的格式是什么?有哪些注意事项? 修饰符+方法名称+(参数列表),构造的方法没有返回值,方法名称要和类名一样,有属性参数的需要在成员变量前加this,参数列表的值要和指定的方法格式相同. ...
- 破解sublim_Text3
1.更改hosts文件 windows系统的hosts文件在C:\Windows\System32\drivers\etc 路径下,其他系统请自行百度 在hosts文件中加入下面两行: 127.0.0 ...
- 浅谈[^>]在正则中的2种用法
/^A/会匹配"An e"中的A,但是不会匹配"ab A"中的A,此时^A的意思是“匹配开头的A” /[^a-z\s]/会匹配"my 3 sister ...