TA的每日心情 | 衰 2021-2-2 11:21 |
---|
签到天数: 36 天 [LV.5]常住居民I
|
1.简介 后端基于spring, struts1和hibernate,前台用bootstrap实现。
" g* A5 m F7 u4 x2 O1 W( l 实现的功能也比较少,基本的crud操作,文件上传,ajax异步刷新等。8 K0 M" @$ y4 Z; e1 C/ B
2.代码结构
g# p! A$ @. o( ]8 D7 G; }6 P( w$ e. k' J6 d
3: applicationContext.xml配置文件
( I$ |6 m1 g$ C" G0 e- <?xml version="1.0" encoding="utf-8"?>; V7 N1 ~$ H" a. a( H, D2 b
- <beans xmlns="http://www.springframework.org/schema/beans" T$ ^$ Q; u; w6 } y2 t
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance": ~: g# Z/ S- o7 {; P
- xmlns:context="http://www.springframework.org/schema/context"
1 R) `! {) J; ^7 Z0 E( Q - xmlns:tx="http://www.springframework.org/schema/tx"
8 L& c7 o9 w: O2 Z! ~& C5 _* S2 y5 b - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
/ }! g. G& }# {1 ^# M - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd+ L3 ~; T. } [- k; o* c
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
7 Z! r, o3 W5 C. k - <!-- 启用注解扫描 -->
) E+ Y( S: X+ F$ A6 b: J' O; x - <context:annotation-config/>
# Y' t& \5 D/ w1 u) i) {6 K+ i3 \7 c
" P& L0 V; g: ]' D T9 I- <!-- 配置数据源 -->3 ~% J" K. s: P4 G) I% U' S
- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">+ \7 O: V; g8 d4 D3 n- o/ F- [" M
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
7 L* {5 R$ z( Y& A0 A _/ h - <property name="url" value="jdbc:mysql://localhost:3306/wireless"/>- O7 g9 U v0 {* O9 u; ?
- <property name="username" value="root"/>
" o! C7 M& \. P6 D/ Y - <property name="password" value="110511"/>
. r$ _: j4 e2 l7 P$ R( l) D2 l - </bean>! F- g( l& Y6 `. _
- <!-- 配置会话工厂 -->
* x* y, I% E! i% q- U' O0 a& U - <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">1 a+ e! ]( O' a
- <!-- 设置数据源 -->
: Z3 t) A; @/ `" n7 J - <property name="dataSource" ref="dataSource" />
* @2 h$ Z% k. L; Z& V% v5 H - <!-- 配置映射文件 -->6 n# f+ V6 _4 l0 i0 Y
- <property name="mappingResources">
! {% q: |+ b) T0 P; v. P - <list>
/ Y2 g. }! I; b: @, {% L - <value>com/wireless/entity/hbm/Usertbl.hbm.xml</value>
6 X8 J6 T4 c, x! Q; d; j$ L - <value>com/wireless/entity/hbm/Menutypetbl.hbm.xml</value>
# I/ B) h0 q- ] - <value>com/wireless/entity/hbm/Tabletbl.hbm.xml</value>$ g; t" K: C5 `, x u4 q
- <value>com/wireless/entity/hbm/Menutbl.hbm.xml</value>9 m& E" V! V8 c* U
- <value>com/wireless/entity/hbm/Ordertbl.hbm.xml</value>+ w* x& w( }4 E/ O9 f, _" n1 R8 B7 E
- <value>com/wireless/entity/hbm/Orderdetailtbl.hbm.xml</value>
7 w( o1 Q3 u6 r - </list>
$ w. ?( V+ D0 H- s, k$ U( h( E - </property>( s8 W( B$ f- @# _1 C4 x
- <property name="hibernateProperties">5 i; F% [8 m! G% L+ G/ I4 Y
- <props>
5 ?4 H& U* Z* J5 _ - <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>0 c0 I4 F' }# y$ E) W, N/ q
- <prop key="hibernate.hbm2ddl.auto">update</prop>1 @& y9 L% c' g9 {' |3 \7 l* z
- <prop key="hibernate.show_sql">true</prop>
* Z5 C4 B+ ^3 `8 H" Y - <prop key="hibernate.cache.use_second_level_cache">true</prop>1 W) n; n8 O4 _
- <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>7 C* ~3 c" J& q* y, }( [5 L
- <prop key=" hibernate.generate_statistics">true</prop>1 |2 o& A* A8 T) `: o3 ?7 B
- ' ?4 I; ?0 r9 U( r
- </props>5 y i4 j' B$ O9 \8 Q
- </property>
|# e% u8 V+ \2 {9 K$ a4 F* H5 J - </bean>* z( \! F# I3 h5 g5 S7 [
- . y2 ?& m; C& S5 M, [8 w
- <!-- 配置Service -->
9 t- a. x2 j* |: d2 W- H" C/ _( Q
6 k. e+ _* Z; W( F- <!-- 配置Service -->7 o! K) H; k4 v
- <bean id="userService" class="com.wireless.web.service.impl.UserServiceImpl" />( l' }4 Z$ |$ G" d; _
- <bean id="tableService" class="com.wireless.web.service.impl.TableServiceImpl" />
6 S0 B* X# s7 j: u9 f1 \$ O% c - <bean id="menuService" class="com.wireless.web.service.impl.MenuServiceImpl" />
5 x; @# }! |; M - <bean id="orderService" class="com.wireless.web.service.impl.OrderServiceImpl" />; ?# D" ?+ A1 {$ _+ Q
$ a4 Z: O+ ~2 N. U$ E$ U- <!-- 配置action ,prototype为原型,每次生成新的action 解决并发问题-->
, W9 L6 H0 i e2 b: w: S* {6 m1 I$ [9 u" w - <bean name="/login" class="com.wireless.web.action.LoginAction" >
, Y' c: [2 k5 D/ t. k, ~ - <property name="userService" ref="userService"></property>
# T3 ~0 N7 `9 ^7 U - </bean>
; q* J# X+ a6 C - <bean name="/home" class="com.wireless.web.action.HomeAction" >, g, x4 b2 P- P
- <property name="userService" ref="userService"></property>9 P3 l! ^) h) @; B. V& d4 J
- </bean>
. b/ x, J! G: g7 s! ~( j& @ - <bean name="/table" class="com.wireless.web.action.TableAction" >1 s7 B2 O/ t6 y7 o8 n9 S
- <property name="tableService" ref="tableService"></property>
1 k, b) y1 G) m, U2 ?/ t* ^ - </bean>. p5 k! {& V( C
- <bean name="/menu" class="com.wireless.web.action.MenuAction" >
( d9 i( F0 D: B# }9 z1 R7 U - <property name="menuService" ref="menuService"></property>, A! i1 ~$ _ I; G
- </bean>0 t* N) K0 W7 ?& s. _
- <bean name="/order" class="com.wireless.web.action.OrderAction" > b" u$ a0 N2 K% H3 O( A: s
- <property name="orderService" ref="orderService"></property>
* W) J N8 q* J" M/ i - </bean>
" m9 H+ b( E& ?( i' C
" N# d Q: [! T6 g- <!-- 配置事务管理器,统一管理sessionFactory的事务 -->
* Q5 [4 S$ q, F5 A+ R: e - <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
: F/ ~0 z* a; v, ^7 v& Z! O - <property name="sessionFactory" ref="sessionFactory"/>9 E" j6 v h/ W+ H% X+ b
- </bean>+ G( [! X# R! B0 R: c& V, J
- <!-- 启用事务注解 -->! X2 Z1 |8 J' n2 H% n" ]4 \
- <tx:annotation-driven transaction-manager="txManager"/>/ j# g1 b2 ], k/ t% ?, h
; S }/ M8 y2 W; I1 v1 q- </beans>
4 P! t4 `% t! U" y: z; {+ p
复制代码 4:hibernate.cfg.xml配置文件
" m2 G4 v3 q( ]- <?xml version='1.0' encoding='UTF-8'?>' l* i7 C: c3 M- C
- <!DOCTYPE hibernate-configuration PUBLIC; f# K. G( h/ h2 o0 b, y
- "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
) g, i1 p5 b! G6 U# D - "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">5 W% w' R. s, U0 }) x* N ?9 X
* e5 v7 M& ^7 e2 g- i) M; K/ r- <!-- Generated by MyEclipse Hibernate Tools. -->
/ |, r3 D- H+ Z9 T5 N, \0 g - <hibernate-configuration>2 ~ t% B2 ]: f# C! u6 S% C- B( H3 C
+ L0 Z1 I, A5 }0 z' Q- <session-factory>
; N' B0 K' \. X4 x# o - <property name="dialect">
& b3 p( ?9 w/ E3 F1 e/ D - org.hibernate.dialect.MySQLDialect6 P. p. O. l+ ~; I% a( b* ^, i
- </property>
/ q- p+ h5 x( L4 Y+ ` - <property name="connection.url">
p( c; H! w- \1 b: @! p | - jdbc:mysql://localhost:3306/struts: }' z1 `$ N6 `( d8 x. c3 r p" G
- </property>4 w6 S2 m: ]2 a9 ?
- <property name="connection.username">root</property>
" U, ~4 x( Z5 m1 O) s& ` - <property name="connection.password">110511</property>
* k3 _& w8 p& [/ j) u$ i - <property name="connection.driver_class">, e& ~" A* S+ i* d
- com.mysql.jdbc.Driver
, G7 Z0 C) U5 K! \3 D, P% k) J: I8 z; S - </property>
4 n2 b9 o0 ~+ V - <property name="myeclipse.connection.profile">mysql</property>% r. j% w v; _
- <mapping resource="com/wireless/entity/hbm/Usertbl.hbm.xml" />
. Y' |* k! D) |3 H' M q/ ] - <mapping resource="com/wireless/entity/hbm/Menutypetbl.hbm.xml" />
8 Y& C9 R K- ` - <mapping resource="com/wireless/entity/hbm/Tabletbl.hbm.xml" />
' E, s+ k0 H, U D - <mapping resource="com/wireless/entity/hbm/Menutbl.hbm.xml" />
& ]2 u' ~' Y/ O8 Y `0 p7 Q5 ^ - <mapping resource="com/wireless/entity/hbm/Ordertbl.hbm.xml" />
1 `1 v) C3 U# w3 E- l7 O - <mapping resource="com/wireless/entity/hbm/Orderdetailtbl.hbm.xml" />
# a! X; V& } m. r8 ?8 b
* u/ u t4 N. Q# W8 Y1 e- </session-factory>
1 ?' r/ f" H& z
! O; B, |: e! {9 K/ D0 `3 n( H- </hibernate-configuration>
复制代码 5:界面展示3 P$ j u8 g3 a: k Z" H, @
. K [; i6 P! `1 I7 v" o, P, a+ b I0 X/ E9 \1 b' i+ L
+ h% B; B& ]: s: O
* W+ z( Q+ i" v4 D5 @4 ^# m
3 s5 D$ o8 b* V: n- _& Z9 @ i
; X$ I0 Y' l5 q" m7 b$ g- d
+ i2 x1 U |( k2 j% \+ ]
0 C; m( b0 C8 Z5 y4 P
% D% s! ?+ m9 C) a8 v2 M1 F; D( g5 U5 c+ v5 N- u
8 k7 s. N# K. H0 B+ w; b7 ]
6 C! N( C2 J: Y' G2 \9 z* L/ Y
, F8 z3 ?5 \ D& O, y8 V! w1 [项目源码下载地址:javaWeb三大框架SSH + BootStrap网上订餐系统
# H% e: ]2 [; d9 C
解压密码:
' a; `: W- J: J& Y/ O. ]# @
4 o# p9 A: O) J% G |5 }+ N: z |
-
总评分: 帮币 + 5
查看全部评分
|