TA的每日心情 | 衰 2021-2-2 11:21 |
---|
签到天数: 36 天 [LV.5]常住居民I
|
1.简介 后端基于spring, struts1和hibernate,前台用bootstrap实现。
6 S! s8 L) t6 j" s2 p1 o 实现的功能也比较少,基本的crud操作,文件上传,ajax异步刷新等。2 S0 @ U8 X# X1 ]9 ^1 Q+ q
2.代码结构
: h' v0 X0 c, X5 }/ i8 x0 T
' R! _, Z# Z t0 R6 J' L: g! g- t3: applicationContext.xml配置文件0 i; V# J1 k9 f, G1 O1 L; y
- <?xml version="1.0" encoding="utf-8"?>
$ M( ~6 u- f5 u' @ - <beans xmlns="http://www.springframework.org/schema/beans"
9 v2 o7 \ h4 e - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- V5 x2 q/ z6 z0 t - xmlns:context="http://www.springframework.org/schema/context"
2 K1 ^! b, `7 j6 a - xmlns:tx="http://www.springframework.org/schema/tx"5 Z5 o0 {5 a3 f, J- [9 g
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
, \3 u$ J* P, O6 E8 } - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd p; l5 h* @; b& d( u/ {5 F% Q
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">6 P h5 V: V( `0 r
- <!-- 启用注解扫描 -->
* [& N- Z% \% L( X) A' Z - <context:annotation-config/>
D- Y% x3 B ]& A2 U - & S2 e. O; |1 \) W3 H1 E( m m n
- <!-- 配置数据源 -->$ c, Y4 e9 X# ^
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
- f3 O+ X, Z% o; f- I - <property name="driverClassName" value="com.mysql.jdbc.Driver" />
& I2 q( o' D7 Y5 ?. i5 Q$ u - <property name="url" value="jdbc:mysql://localhost:3306/wireless"/>
# A( H5 `' O& w% I! z - <property name="username" value="root"/>0 U( J& z0 ]% }1 h
- <property name="password" value="110511"/># Y T6 G6 Q( ]8 L; t
- </bean>
5 ^2 _: Q6 f8 n% J/ K/ G$ \: Z - <!-- 配置会话工厂 -->
! b0 r1 {2 F* \+ D; F" k - <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
3 W" L( ?2 w5 {& Z! [$ u- ^ - <!-- 设置数据源 -->/ j% _: a/ R1 E& j
- <property name="dataSource" ref="dataSource" />" N# L( ?" f. X$ y
- <!-- 配置映射文件 -->6 G6 N" R4 Q5 f* @
- <property name="mappingResources">
: r8 D- N6 R3 p& r - <list>/ \1 A6 j" F4 C8 |6 R' Y$ e+ s
- <value>com/wireless/entity/hbm/Usertbl.hbm.xml</value>
% R" x( U' z9 s3 ?% t" r) L# Z$ r - <value>com/wireless/entity/hbm/Menutypetbl.hbm.xml</value>2 Q1 F' n" W! o
- <value>com/wireless/entity/hbm/Tabletbl.hbm.xml</value>0 P- Y' U4 h- `% s2 [
- <value>com/wireless/entity/hbm/Menutbl.hbm.xml</value>" P+ n- r7 a) s/ p( \" p# ^
- <value>com/wireless/entity/hbm/Ordertbl.hbm.xml</value>
' b+ l+ J% l, w- e5 a5 t - <value>com/wireless/entity/hbm/Orderdetailtbl.hbm.xml</value>
8 d, }1 n/ c3 ^, I - </list>$ G9 e% O+ P" \# o' Y
- </property>0 h/ d$ i) M, z: u
- <property name="hibernateProperties">/ ]; `; ]' E/ A. \
- <props>
7 W1 q# D/ U! H- _# Z - <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
! e& o' e& I- S$ p - <prop key="hibernate.hbm2ddl.auto">update</prop>( R% F/ T. o8 y) Z2 L* K
- <prop key="hibernate.show_sql">true</prop># @7 B% S5 D9 y
- <prop key="hibernate.cache.use_second_level_cache">true</prop>
& v" N+ b3 l! X: |$ n$ ?' } - <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>* K- o* d6 y0 t6 x/ k0 J, ~) y
- <prop key=" hibernate.generate_statistics">true</prop>
7 J2 S4 i5 c0 |8 o5 h -
3 Q# `: E0 o4 |5 T; B# g: b: r - </props>
$ j4 f/ `; R" E' W* ^( r, P+ u - </property>
- _' W0 \9 z* N3 K1 E+ A( n. L1 y - </bean>
4 Y# B% a: F7 j
- |8 p- A4 P* _5 V1 \5 Y9 k- <!-- 配置Service -->
/ n I! D& s6 W! u, ]4 W; ^ - 2 z! s* k4 }' C0 _
- <!-- 配置Service -->; a6 `1 p+ V, i; f6 P5 x+ y
- <bean id="userService" class="com.wireless.web.service.impl.UserServiceImpl" /> ~, `( p) I( @1 r
- <bean id="tableService" class="com.wireless.web.service.impl.TableServiceImpl" />0 x6 x) {" p: J# X% Z4 p, X
- <bean id="menuService" class="com.wireless.web.service.impl.MenuServiceImpl" />
" u2 b! s3 H- ]" R - <bean id="orderService" class="com.wireless.web.service.impl.OrderServiceImpl" />9 H# R: E" j' w( u' X
- / A$ Z* i6 C2 H" Z8 M
- <!-- 配置action ,prototype为原型,每次生成新的action 解决并发问题-->
# C+ m x! r6 V3 V - <bean name="/login" class="com.wireless.web.action.LoginAction" >
) y( d1 o& P& K: \( K - <property name="userService" ref="userService"></property>
# j2 c9 q m7 {/ U - </bean>
& Z/ L! s$ u9 g, I# W9 {8 Q - <bean name="/home" class="com.wireless.web.action.HomeAction" >
& z/ R8 Z- P1 d4 I+ T9 }- _ - <property name="userService" ref="userService"></property>
0 l1 H# D# r2 D - </bean>
% c$ q3 N7 n) S, c8 } - <bean name="/table" class="com.wireless.web.action.TableAction" >6 J6 y% D" r, ?# d( `! j7 W# H$ f
- <property name="tableService" ref="tableService"></property>% g" X" K* |% r4 V, [2 K) a
- </bean>
9 ~, B* |) t, o3 b- h - <bean name="/menu" class="com.wireless.web.action.MenuAction" >
( E$ k) m R% a& J1 l - <property name="menuService" ref="menuService"></property>6 g- I9 `3 W5 e% ^3 q
- </bean>
* G9 k; h$ \: ~) g - <bean name="/order" class="com.wireless.web.action.OrderAction" >9 m" U7 Q1 K" V! y8 v
- <property name="orderService" ref="orderService"></property># o$ D% a! C) k4 M
- </bean>3 M; g" u8 L2 }2 M9 Y
- - Z( `* g* k, `
- <!-- 配置事务管理器,统一管理sessionFactory的事务 -->9 _2 K! q+ v$ ]+ g2 P9 B- }
- <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- H" U+ ]; K3 w, x" @" ] - <property name="sessionFactory" ref="sessionFactory"/>' M/ f. J8 R' ]* [
- </bean>
! B+ g- d3 f# F3 Z/ [ - <!-- 启用事务注解 -->& V/ W- r; @; p$ @. R( X
- <tx:annotation-driven transaction-manager="txManager"/>
& ?7 }/ p) Z5 [* J# Z5 [4 L' d
- h/ d1 R% l+ y" S) `- </beans>6 i$ y6 J% V, q3 b. D( Q
复制代码 4:hibernate.cfg.xml配置文件
. u3 k. z5 c, O9 a, H/ E& k! ^8 E- <?xml version='1.0' encoding='UTF-8'?>
* f2 r) q* B" O4 l3 a3 n - <!DOCTYPE hibernate-configuration PUBLIC
+ o! v, d( S8 K* B2 d! ~! r0 N - "-//Hibernate/Hibernate Configuration DTD 3.0//EN"# b- T7 W5 Q* S, B
- "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
- `( W; W$ K( h7 |8 d8 F/ q - & M& s- W0 C# g# G& o Y. T$ E
- <!-- Generated by MyEclipse Hibernate Tools. -->
; h7 U3 y& T. x# |, p1 A) i - <hibernate-configuration>
' {5 N4 T8 W$ L& \9 m - m* R* D4 z0 {1 \) L
- <session-factory>
/ s% W' h3 ^& u! q6 l6 J - <property name="dialect">
0 K4 q7 E$ M9 ]) w - org.hibernate.dialect.MySQLDialect3 c( {. a) s0 O, R* T
- </property>+ S" n9 k2 C8 o2 w: e! F1 w
- <property name="connection.url">2 H6 K1 t- F R* z: T6 d& A
- jdbc:mysql://localhost:3306/struts# K9 u. V; ? w0 E/ w2 i
- </property>1 l. E0 z5 h/ O, q, P
- <property name="connection.username">root</property>
* h4 i) o* j9 I& H! Y - <property name="connection.password">110511</property>/ V+ E$ J, H) t
- <property name="connection.driver_class">
0 J* W: D* U4 Z - com.mysql.jdbc.Driver2 |. A7 \9 z! F9 c# J
- </property>2 b' a; w1 o* M; y+ y4 G
- <property name="myeclipse.connection.profile">mysql</property>
- H2 h. c( T, z3 V' H0 \! T/ z - <mapping resource="com/wireless/entity/hbm/Usertbl.hbm.xml" />
( z8 H+ w0 ?* ?1 n3 }" A) l - <mapping resource="com/wireless/entity/hbm/Menutypetbl.hbm.xml" />
+ i$ ?7 {7 P0 y$ R - <mapping resource="com/wireless/entity/hbm/Tabletbl.hbm.xml" />8 A' ?2 \% [. f+ `% M
- <mapping resource="com/wireless/entity/hbm/Menutbl.hbm.xml" />! k& A3 _$ o5 N4 _/ s# b
- <mapping resource="com/wireless/entity/hbm/Ordertbl.hbm.xml" />
5 M. U0 G* O; e" s* q - <mapping resource="com/wireless/entity/hbm/Orderdetailtbl.hbm.xml" />
/ e9 X# X; P. x( @7 ]5 ^3 d( }9 r - 9 q8 M6 j+ g: W0 |, v, s n' ^5 e
- </session-factory>
) z' @0 O1 c. k# A* \ - 9 M0 M. g6 R9 t! v/ c: ]/ o( Z
- </hibernate-configuration>
复制代码 5:界面展示; j% F: {2 k9 d; m$ b* ~: E
2 _, i6 p5 `3 @4 E4 D( V8 G+ Z4 T; t; c# M) s! m+ `( I0 _
1 u- C1 k d; ^' c) x
( l/ F& H( R# r% J& P( ^$ [
% ]) y1 p) V, d* L+ C7 u
# G( J' K( N5 u. q. M
! _1 R3 H& h8 W7 T3 T) p5 T
1 a$ k0 _% G1 O) D2 {) j# H
" D+ f9 _7 R3 U% {
( w c, ^$ t5 L# V
) N% Z6 @4 |& x( w4 j
$ I- w ~- ?* f' k6 |! {" |9 f
: `$ u7 K" G, S- y. `& I! N% W项目源码下载地址:javaWeb三大框架SSH + BootStrap网上订餐系统 B4 P( T' v& x& s/ f0 C
解压密码:8 h+ J2 o* j Z; T# w2 U; P( p" V
9 P* b1 j5 F% a6 X& C: @ |
-
总评分: 帮币 + 5
查看全部评分
|