struts2 Convention插件好处及使用】的更多相关文章

现在JAVA开发都流行SSH.而很大部分公司也使用了struts2进行开发..因为struts2提供了很多插件和标签方便使用..在之前开发过程中总发现使用了struts2会出现很多相应的配合文件.如果对配置文件的管理感觉比较麻烦..可以考虑使用COnvention插件可以进行零配置而且插件进行很多规范的约定也可以对开发合作当中按着它相应的规律开发..感觉也挺方便管理的.下面简单介绍它的使用. 首先我们需要使用到的jar包: struts2-convention-plugin-2.1.8.jar…
package com.hyy.action; import java.util.HashMap; import java.util.Map; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.ParentPackage; import org.apache.struts2.convention.annotation.Result; imp…
刚刚查阅官方文档(convention-plugin.html)并学习了Struts2的Convention插件,文章这里只作为一个笔记,建议大家去看官方文档比较清晰和全面. 需要在项目添加这些包 convention先找package,其中如果package包含action这个单词,就会将这个包作为根路径,即namespace="/" 然后找类,如果一个类的类名称是Action结尾,或者继承了ActionSupport类,那么会将该类作为action类,对应的url为 例如: com…
从struts21开始,struts2不再推荐使用codebehind作为零配置插件,而是改用Convention插件来支持零配置.与以前相比较,Convention插件更彻底. 使用Convention插件,需要将struts2-convention-plugin-2.3.1.2.jar文件复制到lib目录中即可 这个插件是自动搜索action的功能: 规则如下:它会自动搜索位于action,actions,struts.struts2包下的java类.   Convention插件会把如下两…
1.struts2自2.1以后推荐使用Convention Plugin支持struts零配置支持(引入jar:struts2-convention-plugin-2.x.x.jar)①convention默认扫描所有实现com.opensymphony.xwork2.Action的类和指定包路径下以Action结尾的类名②struts.convention.package.locators指定默认的根packages,struts.convention.action.packages指定搜索的…
package com.hyy.action; import org.apache.struts2.convention.annotation.Action; import com.opensymphony.xwork2.ActionSupport; public class HelloWorldTest extends ActionSupport{ private String message; @Action("/different/url") public String test…
第一步,引入struts2-convention-plugin-2.2.1.jar 然后,改动配置文件. 我是在struts.properties文件里改动的: struts.objectFactory = spring struts.devMode = true struts.i18n.encoding = UTF-8 struts.convention.result.path =/WEB-INF/jsp/ struts.convention.package.locators = action…
转自:http://chenjumin.iteye.com/blog/668389 1.常量说明 struts.convention.result.path="/WEB-INF/content/": 结果页面存放的根路径,必须以 "/" 开头. struts.convention.action.suffix="Action": action名字的获取 struts.convention.action.name.lowercase="tr…
package com.hyy.action; import com.opensymphony.xwork2.ActionSupport; public class HelloWorld extends ActionSupport{ private String message; public String execute() { message = "hyy"; return INPUT; } public String getMessage() { return message;…
一.首先说明一点:所谓的基于Convention插件的约定优于配置的使用,并不是严格意义上的零配置,struts.xml文件并不能完全舍弃. 获得Convention插件功能,所必需的jar包有:|asm-x.x.jar|asm-commons-x.x.jar|struts2-convention-plugin-x.x.jar| 如果将struts2-config-browser-plugin-x.x.jar放入项目中,则可以通过http://{ip}:{port}/{Application}/…
最近接触到一个新的项目,是做一个使用S2SH的电子商务商城的二次开发.之前使用过S2SH,在此之前的项目中,Struts2 使用的是XML配置而这个项目是使用注解.在这个项目中,注解还不需要使用Action注解,struts会自动识别了指定包下的所有action文件,我只需要配置result和过滤器就可以了.刚开始接触的时候,有点不习惯,但却觉得这样蛮好用的,后来了解了一下,这个是使用了Struts 2的convertion配置,主要的是要实现“约定优于配置”这个说法,这样做,只需要在配置文件进…
Struts2的Convention插件的作用:在Struts2中的/lib/struts2-convention-plugin-x.x.xx.x.jar Convention插件会自动搜索位于action,actions,struts,struts2包下的所有类,即它会把如下两种的Java类当初Action处理:    所有实现了com.opensymphony.xwork2.Action的Java类    所有类名为Action结尾的Java类 例如:    com.app.action.L…
考虑使用COnvention插件可以进行零配置而且插件进行很多规范的约定也可以对开发合作当中按着它相应的规律开发..感觉也挺方便管理的.下面简单介绍它的使用. 首先我们需要使用到的jar包: Java代码 struts2-convention-plugin-2.1.8.jar struts2-core-2.1.8.jar xwork-core-2.1.6.jar commons-fileupload-1.2.1.jar freemarker2.3.16.jar struts2-conventio…
主要用于Action映射和Result映射 struts2-convention-plugin-2.3.16.3.jar 会将 |--实现了com.opensymphony.xwork2.Action的Java类         |--类名以Action结尾的Java类 作为Action   Convention插件允许设置如下三个常量:         struts.convention.exclude.packages    不扫描哪些包         struts.convention.…
java.lang.RuntimeException: Invalid action class configuration that references an unknown class named [userRegisterAction]org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100) 整合过程完毕,但是在转发视图是会出现这样的错…
v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} Normal 0 false 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE /* Style Definitions */ table.MsoNormalTable {…
Struts2 Convention Plugin ( struts2 零配置 ) convention-plugin 可以用来实现 struts2 的零配置.零配置的意思并不是说没有配置,而是通过约定大于配置的方式,大量通过约定来调度页面的跳转而使得配置大大减少.考虑到某种因素,这里采用 myeclipse 作为示例 IDE,环境 : JDK 1.6 myeclipse 8.6.1 struts 2.1.8 web.xml   <filter>       <filter-name&g…
插件 Struts-plugin.xml 说明: Struts-plugin.xml文件是在tomcat服务器启动的时候加载的 该配置文件在classpath的根目录下 在每一个含有plugin字母的jar包的根目录下有一个struts-plugin.xml文件 当tomcat启动的时候,就把所有的含有plungin的jar包的该配置文件就加载了. 静态注入 1.  在struts2的配置文件中写的bean 在tomcat启动的时候,会执行OgnlValueStackFactory的create…
http://blog.csdn.net/spyjava/article/details/13631961系列课程使用 注解:http://www.yiibai.com/struts_2/struts-2-hello-world-annotation-example.html http://blog.csdn.net/llbupt/article/details/6639782 文档下载 http://wenku.baidu.com/link?url=fTG98v9CtaSTXVK6q90QCZ…
1. 导入包: json-lib-2.3-jdk15.jar struts2-json-plugin-2.3.15.3.jar 2. 在struts.xml中修改配置如下: <package name="default" namespace="/" extends="json-default"> <global-results> <result name="ajax" type="jso…
一.struts2-convention-plugin配置文件具体解释 <constant name="struts.convention.actionConfigBuilder" value="convention"/>   <constant name="struts.convention.actionNameBuilder" value="convention"/>   <constant…
1. 零配置使用struts2-convention-plugin-2.3.16.jar,rest使用struts2-rest-plugin-2.3.16.jar 1.1 Struts2的convention插件的主要特点是“约定优于配置”,对于Struts2而言,它会自动在你创建的action.actions.struts.struts2这四个包下自动搜索,只要实现了com.opensymphony.xwork2.Action接口的类或者是类名以“Action”结尾的类,Struts2就会认为…
从struts2.1开始,struts2不再推荐使用Codebehind作为零配置插件,而是改为使用Convention插件来支持零配置,和Codebehind相比,Convention插件更彻底,该插件完全抛弃配置信息,不仅不需要是使用struts.xml文件进行配置,甚至不需要使用Annotation进行配置,而是由struts2根据约定自动配置. 如何使用Convention 1.       将struts-Convention-plugin-2.1.6.jar文件复制到WEB-INF/…
又是周末,继续Struts2的学习,之前学习了,Struts的原理,Actions以及Results,今天对对Struts的Convention Plugin进行学习,如下图: Struts Convention支持零配置进行开发,也就是约定约定优于配置的方式. (1)环境准备 使用Convention Plugin进行开发,需要引入struts2-convention-plugin,完整的pom.xml依赖如下: <dependency> <groupId>org.apache.…
用了Convention插件来实现所谓的0配置, 1. struts.convention.package.locators.basePackage=com.ZTest.web.action 这个属性用于约定Action 类的根包(这个包是Java 类的包,而不是Struts.xml中配置的<package>节点) 例如: 在一个项目中有这样一系列的Java 包,那么当指定convention的这个属性,Struts 框架就会在你访问特定的URL时会自动的找到所要的请求的实现类. 当你在浏览器…
Struts2的配置 Struts2可以通过Convention插件管理Action和结果映射,也可以通过使用XML文件进行管理,这两种方式各有好处:使用Convention插件管理减少了XML文件的编写量,根据"约定"的方式寻找相关Action或结果映射,相对于使用XML文件配置便于开发,但最大的弊端是后期不利于维护和修改,所以建议考虑使用XML文件管理Struts2的配置信息. 常量配置: Struts2的常量对应用的整体起作用,也被称为Struts2属性. Struts2配置常量…
[前言]所谓快速开发,实质上为了节省项目的开支成本,减少程序员的开发时 间,固然就形成了种种二次封装的框架,也就是造轮子,然后我们的程序就按照这个轮子去画瓢,这里我就把公司这几次开发系统的框架源码贴出来,做一下讲解以 及使用示范,并有附件提供参考,希望能给各位在基于后台管理系统提供帮助.[目录]        1.struts2的配置        2.struts2的基类构成        3.具体实例应用[内容]           一.struts2的配置    1 .struts2的过滤…
Convention 插件 从 Struts 2.1 开始, Struts 可以使用 Convention 插件来支持零配置: Convention 插件完全抛弃配置信息, 不仅不需要使用 struts.xml 文件进行配置, 甚至不需要使用 Annotation 进行配置. 而是完全根据约定来自动配置. 安装 Conversion 插件: 复制 struts-2.2.1\lib\struts2-convention-plugin-2.2.1.jar 到当前当前 WEB 应用的 WEB-INF…
1.在web.xml文件中定义核心Filter来拦截用户请求. <!-- 定义Struts 2的核心Filter --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter>…