一、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使用的更多相关文章

  1. java痛苦学习之路[十]--日常问题汇总

    FIddler2 1.FIddler2  request请求的參数出现中文乱码问题时,须要进行一下设置: 打开注冊表编辑器,找到HKCU\Software\Microsoft\Fiddler 2\,在 ...

  2. java痛苦学习之路[十二]JSON+ajax+Servlet JSON数据转换和传递

    1.首先client须要引入 jquery-1.11.1.js 2.其次javawebproject里面须要引入jar包  [commons-beanutils-1.8.0.jar.commons-c ...

  3. Java NIO 学习笔记(四)----文件通道和网络通道

    目录: Java NIO 学习笔记(一)----概述,Channel/Buffer Java NIO 学习笔记(二)----聚集和分散,通道到通道 Java NIO 学习笔记(三)----Select ...

  4. Struts2 Convention Plugin ( struts2 零配置 )

    Struts2 Convention Plugin ( struts2 零配置 ) convention-plugin 可以用来实现 struts2 的零配置.零配置的意思并不是说没有配置,而是通过约 ...

  5. java的学习之路01

    [原创 - 尚学堂科技 - 马士兵老师] JAVA自学之路 一:学会选择 [转载请注明出处:http://www.bjsxt.com/zixue/zixuezhilu_1.html] 为了就业,不少同 ...

  6. Redis——学习之路四(初识主从配置)

    首先我们配置一台master服务器,两台slave服务器.master服务器配置就是默认配置 端口为6379,添加就一个密码CeshiPassword,然后启动master服务器. 两台slave服务 ...

  7. Java的学习之路

    记事本 EditPlus eclipse Java的学习软件,已经系统性学习Java有一段时间了,接下来我想讲一下我在Java学习用到的软件. 1.第一个软件:记事本 记事本是Java学习中最基础的编 ...

  8. Java开发学习(二十四)----SpringMVC设置请求映射路径

    一.环境准备 创建一个Web的Maven项目 参考Java开发学习(二十三)----SpringMVC入门案例.工作流程解析及设置bean加载控制中环境准备 pom.xml添加Spring依赖 < ...

  9. [原创]java WEB学习笔记55:Struts2学习之路---详解struts2 中 Action,如何访问web 资源,解耦方式(使用 ActionContext,实现 XxxAware 接口),耦合方式(通过ServletActionContext,通过实现 ServletRequestAware, ServletContextAware 等接口的方式)

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

随机推荐

  1. Java Socket通讯---网络基础

    java socket 通讯 参考慕课网:http://www.imooc.com/learn/161 一.网络基础知识 1.1 通讯示意图 1.2 TCP/IP协议 TCP/IP是世界上应用最为广泛 ...

  2. APM技术原理

    链接地址:http://www.infoq.com/cn/articles/apm-Pinpoint-practice 1.什么是APM? APM,全称:Application Performance ...

  3. [Offer收割]编程练习赛32

    气泡图 两两判断关系,dfs. #include<stdio.h> #include<string.h> #include<stdlib.h> #include&l ...

  4. PHP中的字符串类型

    PHP支持两种类型的字符串,这些字符串用引号说明. 1.如果希望赋值一个字面意义的字符串,精确保存这个字符串的内容,应该用单引号标注,例如: $info='You are my $sunshine'; ...

  5. VHDL_LIB之DFF

    1 D-Flip-Flop with async reset or set library IEEE; use ieee.std_logic_1164.all; entity FFD is gener ...

  6. Solid Angle of A Cubemap Texel - 计算Cubemap的一个像素对应的立体角的大小

    参考[http://www.rorydriscoll.com/2012/01/15/cubemap-texel-solid-angle/] 计算diffuse irradiance map或者求解sh ...

  7. OpenCV、OpenCL、OpenGL、OpenPCL

    对于几个开源库的总结,作为标记,以前看过,现在开始重视起来!更详细资料请移步 开源中国社区! 涉及:OpenCV,OpenCL,OpenGL,OpenPCL 截止到目前: OpenGL的最新版本为4. ...

  8. Webstorm 破解2017.1 for Mac

    废话不多说,改了去年分享2016版本的文章,给同学们带来2017.1版本的Mac版本.(win版本网上很多,我这里就不贴出来了). 1.去官仿下载最新的版本  https://www.jetbrain ...

  9. 插入排序InsertSort

    插入排序:从第二个数开始  一直和前面的数组比较 获得排序定位 ​ 代码 /** *插入排序 */ public class InsertSort { public static void inser ...

  10. Kattis - iBoard

    iBoard After years of success with a single-button mouse, a well known computer company has decided ...