基于全注解方式的SSH基础框架 - ssh-base-framework
fmms
13年前
概 述:基于struts2.23 + spring2.5.6 + hibernate3.6.4 + hibernate-generic-dao1.0(除了spring,我整合的都是最新的GA包,hibernate-generic-dao是 google项目库中一个开源的basedao,我灰常喜欢,因为我找不到更好更适合我的)
项目代码是基于eclipse3.6创建的,很简单,大家直接导入则可运行。
1.包结构,源码,测试用例,配置文件一目了然。每个功能模块都在modules包下做开发,配置文件统一在resource管理(基实也没多少配置文件,都用注解嘛)。
2.无论阅读哪个web项目代码,我都是先从web.xml开始,项目有什么东西一清二楚。
我 这里将log4j监听放在第一,我想他应该能够从系统启动开启就能记录我的所有日志(求认证)。第二个监听是proxool数据库连接池,听说很高效,所 以果断引入(引入步骤搞得复杂吧,我还重写了监听。一切为了稳定,也好扩展我某日喜欢加入动态切换数据源做准备。呵呵)。 OpenSessionInView,我想如果你不喜欢可以摘掉,反正我很喜欢。Struts2指定了自定义的struts.xml文件位置,指定扫描注 解的action路径。最后是proxool的可视化图形监控,很棒。
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>framework</display-name> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/classes/resources/log4j/log4j.properties</param-value> </context-param> <context-param> <param-name>propertyFile</param-name> <param-value>/WEB-INF/classes/resources/hibernate/proxool.properties</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:resources/spring/applicationContext.xml</param-value> </context-param> <!-- log4j Listener --> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <!-- Proxool Listener --> <listener> <listener-class>org.chinasb.framework.core.db.ProxoolListener</listener-class> </listener> <!-- Open Session In View Filter --> <filter> <filter-name>OpenSessionInViewFilter</filter-name> <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class> <init-param> <param-name>singleSession</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>OpenSessionInViewFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Spring Listener --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- Character Encoding Filter --> <filter> <filter-name>Set Character Encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <!-- 强制进行转码 --> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>Set Character Encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 延长action中属性的生命周期, --> <filter> <filter-name>struts-cleanup</filter-name> <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class> </filter> <filter-mapping> <filter-name>struts-cleanup</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Struts2 Filter --> <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> <init-param> <param-name>config</param-name> <param-value>struts-default.xml,struts-plugin.xml,resources/struts/struts.xml</param-value> </init-param> <init-param> <param-name>actionPackages</param-name> <param-value>org.chinasb.framework.modules</param-value> </init-param> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Proxool Monitoring --> <servlet> <servlet-name>Admin</servlet-name> <servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Admin</servlet-name> <url-pattern>/admin.html</url-pattern> </servlet-mapping> <!-- Welcome List --> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>