大二那会学习java学web的时候折腾了一个简单的无线点餐系统,cms形式的一个简单网站。
现在马上大四了,一年多没搞这方面发现东西忘得还真快,整理一下,顺便开源了。
1.简介
后端基于spring, struts1和hibernate,前台用bootstrap实现。
实现的功能也比较少,基本的crud操作,文件上传,ajax异步刷新等。
关于bootstrap的学习,请移步 Bootstrap中文网
2.代码结构和类图结构
3 applicationContext.xml配置文件
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 启用注解扫描 --> <context:annotation-config/> <!-- 配置数据源 --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/wireless"/> <property name="username" value="root"/> <property name="password" value="110511"/> </bean> <!-- 配置会话工厂 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 设置数据源 --> <property name="dataSource" ref="dataSource" /> <!-- 配置映射文件 --> <property name="mappingResources"> <list> <value>com/wireless/entity/hbm/Usertbl.hbm.xml</value> <value>com/wireless/entity/hbm/Menutypetbl.hbm.xml</value> <value>com/wireless/entity/hbm/Tabletbl.hbm.xml</value> <value>com/wireless/entity/hbm/Menutbl.hbm.xml</value> <value>com/wireless/entity/hbm/Ordertbl.hbm.xml</value> <value>com/wireless/entity/hbm/Orderdetailtbl.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.cache.use_second_level_cache">true</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> <prop key=" hibernate.generate_statistics">true</prop> </props> </property> </bean> <!-- 配置Service --> <!-- 配置Service --> <bean id="userService" class="com.wireless.web.service.impl.UserServiceImpl" /> <bean id="tableService" class="com.wireless.web.service.impl.TableServiceImpl" /> <bean id="menuService" class="com.wireless.web.service.impl.MenuServiceImpl" /> <bean id="orderService" class="com.wireless.web.service.impl.OrderServiceImpl" /> <!-- 配置action ,prototype为原型,每次生成新的action 解决并发问题--> <bean name="/login" class="com.wireless.web.action.LoginAction" > <property name="userService" ref="userService"></property> </bean> <bean name="/home" class="com.wireless.web.action.HomeAction" > <property name="userService" ref="userService"></property> </bean> <bean name="/table" class="com.wireless.web.action.TableAction" > <property name="tableService" ref="tableService"></property> </bean> <bean name="/menu" class="com.wireless.web.action.MenuAction" > <property name="menuService" ref="menuService"></property> </bean> <bean name="/order" class="com.wireless.web.action.OrderAction" > <property name="orderService" ref="orderService"></property> </bean> <!-- 配置事务管理器,统一管理sessionFactory的事务 --> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"/> </bean> <!-- 启用事务注解 --> <tx:annotation-driven transaction-manager="txManager"/> </beans>
4 源码下载
使用的话需要先创建数据库wireless,将sql文件导入数据库,然后修改上面的application.xml中数据库的配置参数
5 效果展示