零配置

struts2零配置(struts-Convention-plugin)

感情迁移 提交于 2019-12-10 07:20:52
从 struts2.1 开始, struts2 不再推荐使用 Codebehind 作为零配置插件,而是改为使用 Convention 插件来支持零配置,和 Codebehind 相比, Convention 插件更彻底,该插件完全抛弃配置信息,不仅不需要是使用 struts.xml 文件进行配置,甚至不需要使用 Annotation 进行配置,而是由 struts2 根据约定自动配置。 如何使用 Convention 1. 将 struts-Convention-plugin-2.1.6.jar 文件复制到 WEB-INF/lib 路径下 2. 对于 Convention 插件而言,它会自动搜索位于 action , actions , struts , struts2 包下的所有 java 类, Convention 插件会把如下两种 java 类当成 Action 处理: 1) 所有实现了 com.opensymphony.xwork2.Action 的 java 类 2) 所有类名以 Action 结尾的 java 类 3. Convention 插件还允许设置如下三个常量: 1) struts.Convention.exclude.packges: 指定不扫描哪些包下的 java 类,位于这些包结构下的 java 类将不会自动映射成 Action ; 2) struts

eclipse下搭建SSH整合环境(Struts2+Spring+Hibernate+maven)

旧巷老猫 提交于 2019-12-01 09:11:15
1,创建一个maven工程,在选择Archetype时选择webapp: 2,下一步配置maven的pom.xml文件,获取依赖的jar包: <!-- struts2核心包 --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.3.1.2</version> </dependency> <!-- struts2与spring整合的包 --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-spring-plugin</artifactId> <version>2.3.1.2</version> </dependency> <!-- 在 Struts2中要使用 Ajax获得Json数据。要使用Ajax必须引用此Jar --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-json-plugin</artifactId> <version>2.3.1.2</version> </dependency> <!-- Hibernate核心包 -->