TA的每日心情 | 衰 2021-2-2 11:21 |
---|
签到天数: 36 天 [LV.5]常住居民I
|
1.简介 后端基于spring, struts1和hibernate,前台用bootstrap实现。
, \/ L G( k$ Y3 Y8 U* ^- B& g. U 实现的功能也比较少,基本的crud操作,文件上传,ajax异步刷新等。# K- Q3 {6 ~) X& V
2.代码结构
9 G/ P' f) q/ j+ i6 V& `' f/ ~8 t0 j5 u9 P. a5 B
3: applicationContext.xml配置文件
: Z8 C- Q6 M6 r- <?xml version="1.0" encoding="utf-8"?>
: }- i" z9 S, i% e$ M5 i - <beans xmlns="http://www.springframework.org/schema/beans"$ T5 E/ t7 S7 c* B! h6 r" \
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"2 n: h2 }% @, o8 M& ~- A
- xmlns:context="http://www.springframework.org/schema/context"3 m. @/ w( O0 U; ]7 D1 B1 @
- xmlns:tx="http://www.springframework.org/schema/tx"( x6 N7 {' d7 m% C2 a% ?! r
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd2 `+ F. N! @5 x4 B7 q
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd+ Z! a0 z& |4 s
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
" b9 d$ g3 m( n Z. V0 p - <!-- 启用注解扫描 -->: g. C: j! t. Y& d2 B2 g9 o$ q
- <context:annotation-config/>
( }, h: y* t) c! P8 v
! g1 g, H# ^0 g' z2 K- <!-- 配置数据源 -->
6 H% v# M' H1 Q3 ]2 j - <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">7 O/ P( B6 e+ K
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />) B0 T, E9 M. Z+ v5 h" ]
- <property name="url" value="jdbc:mysql://localhost:3306/wireless"/>& o5 o& L* x, o2 E4 C B
- <property name="username" value="root"/>- p) J5 E, [3 ~3 Y/ m0 K( f
- <property name="password" value="110511"/>
& J2 k% v4 m2 f6 C2 A8 l - </bean>) l( Q( g$ a6 A T8 i
- <!-- 配置会话工厂 -->
; y3 t$ [/ E$ K! N( D - <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
" _5 v, |4 U4 z# @9 Z4 A1 d - <!-- 设置数据源 -->3 n7 o" B r8 R$ b# Q/ d
- <property name="dataSource" ref="dataSource" />; ]2 N+ ]; X( [4 V- I$ x2 f5 u
- <!-- 配置映射文件 -->/ _# @* q" d! D( Q0 z* J Q2 e4 C
- <property name="mappingResources">
8 k4 B$ ~* p' X8 n- m8 N - <list>. E4 P3 [# V. s1 \5 Y: y- w; ]$ t
- <value>com/wireless/entity/hbm/Usertbl.hbm.xml</value>
! x: G x5 o. N& G9 x% J - <value>com/wireless/entity/hbm/Menutypetbl.hbm.xml</value>4 c' F5 ~7 q7 B* m# p
- <value>com/wireless/entity/hbm/Tabletbl.hbm.xml</value>
: d9 E3 ] S5 Z' L0 c+ e$ Y - <value>com/wireless/entity/hbm/Menutbl.hbm.xml</value>
8 }7 [0 P9 f0 h7 c3 J0 f( S) F { - <value>com/wireless/entity/hbm/Ordertbl.hbm.xml</value>
" q9 F: q- t! P4 d- E - <value>com/wireless/entity/hbm/Orderdetailtbl.hbm.xml</value>* Z# _& K i v5 J2 b
- </list>
6 s% G5 w& E4 D$ `1 w% ~( K( c - </property>
- J" L0 L8 x. B: `# X - <property name="hibernateProperties">
! D r/ N' f+ D - <props>
; n7 Y' E3 X& A9 q- z - <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
0 P- a" D# T0 d: ?1 o3 @ - <prop key="hibernate.hbm2ddl.auto">update</prop>
9 Y8 E8 B9 p: X8 \8 l! f - <prop key="hibernate.show_sql">true</prop>; n- H0 u; S% z2 h7 V
- <prop key="hibernate.cache.use_second_level_cache">true</prop>
p8 H; `# \4 \7 h1 _( {5 | - <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
4 s7 @! h! Z3 [! U1 F$ | - <prop key=" hibernate.generate_statistics">true</prop>
: T& Q6 H! z9 N5 k -
6 ^5 A" q! E6 U; g - </props>3 |- r8 E- U1 v# a- F- w' D
- </property>
5 k3 Y8 |2 A4 c" m$ I - </bean>
: f/ ?5 s$ }3 p
; A/ a% T; m4 |; F- <!-- 配置Service -->$ q* |% G/ X6 }, S' z
- 0 U/ b+ z3 P, P# X$ ^3 N
- <!-- 配置Service -->/ I$ G. M) b8 n0 D/ d9 Y
- <bean id="userService" class="com.wireless.web.service.impl.UserServiceImpl" />
1 o5 E: \4 Y3 g/ v: { ]8 ` - <bean id="tableService" class="com.wireless.web.service.impl.TableServiceImpl" />
& t4 _9 e1 _; f/ [) L8 u! b - <bean id="menuService" class="com.wireless.web.service.impl.MenuServiceImpl" />; |& @: U: S; Y8 U, x& Z
- <bean id="orderService" class="com.wireless.web.service.impl.OrderServiceImpl" />
, l/ x2 `) H1 Y
" v6 K& r1 Z: d' J& S- <!-- 配置action ,prototype为原型,每次生成新的action 解决并发问题-->
0 M3 D4 a7 ]% Q R - <bean name="/login" class="com.wireless.web.action.LoginAction" >( ?: t+ D2 F7 L+ v+ ?
- <property name="userService" ref="userService"></property>+ b5 K: u3 M/ ?% l3 m
- </bean>- P- V( |$ Q6 s- }+ c/ Y
- <bean name="/home" class="com.wireless.web.action.HomeAction" ># |4 V$ k" G t
- <property name="userService" ref="userService"></property> e$ X0 @, m( L$ ^" X; I9 G
- </bean>3 [ x1 R5 e2 S
- <bean name="/table" class="com.wireless.web.action.TableAction" >
- h) ?, S' I- _% @; [2 p - <property name="tableService" ref="tableService"></property>
' a9 U. N9 A. I* j# h' m, _ - </bean>; Y! O3 L7 r9 }! S7 z5 q" \5 r
- <bean name="/menu" class="com.wireless.web.action.MenuAction" >; K8 C# E$ V, A3 ]9 C
- <property name="menuService" ref="menuService"></property>
' {' c+ e+ V; a5 n3 j - </bean>
- i2 [; p6 @# L1 p - <bean name="/order" class="com.wireless.web.action.OrderAction" >
1 d$ B( d( S1 R4 } - <property name="orderService" ref="orderService"></property>9 ^6 n: r4 d" c8 [* h( T
- </bean>& [9 q# X/ g+ o& x
1 H/ D8 c0 q3 K- S: K) k" i0 K- <!-- 配置事务管理器,统一管理sessionFactory的事务 -->
* D6 K: h4 ]; F4 _8 ?8 V5 i# p( D - <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">5 A1 s& t% L/ K2 S M
- <property name="sessionFactory" ref="sessionFactory"/>
0 O; C1 Z( m( W: v# j! Z - </bean>
2 J# q: T ^* |- f - <!-- 启用事务注解 -->' o- m X$ T5 t4 i) t6 v
- <tx:annotation-driven transaction-manager="txManager"/>' Z# r! X: s9 F- s% ]
: f9 [4 F8 C" z4 v6 v0 n- </beans> R5 {& u0 J8 L" h& J
复制代码 4:hibernate.cfg.xml配置文件6 v) U1 r; l+ ~2 |4 f3 `* M1 r0 k
- <?xml version='1.0' encoding='UTF-8'?>0 z2 @' v' ^* O6 m( B; U6 t
- <!DOCTYPE hibernate-configuration PUBLIC: g- ^2 e( Z' J) P
- "-//Hibernate/Hibernate Configuration DTD 3.0//EN"- O& t, U. ?# N7 L" n
- "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
W+ h$ s4 P" c! Z4 K/ q - 9 E# w( d4 G9 P! i6 |/ l
- <!-- Generated by MyEclipse Hibernate Tools. -->
/ q9 l W/ E( x2 D- N# p' f' r - <hibernate-configuration>2 A5 J( V" z! D v
( C) A" t: O5 _- <session-factory>
8 _) J# w) I+ s) g: b% E - <property name="dialect">. n+ b" C" Z }
- org.hibernate.dialect.MySQLDialect/ [) h7 z- I# }' q7 p/ F
- </property>) c7 S& t: \4 \! a6 |- G- Z( [
- <property name="connection.url">
8 k0 D& W, M! ^3 ^$ g: o - jdbc:mysql://localhost:3306/struts
' e4 p6 \' f* T' W# I3 s - </property>2 M$ e0 \$ K! \. w
- <property name="connection.username">root</property>
# Z% v) I. {" b, n. k - <property name="connection.password">110511</property>& }2 t2 ]. b' h" Z# y2 J! l
- <property name="connection.driver_class">
/ K0 r- n: n; T1 d* j - com.mysql.jdbc.Driver
$ G* v1 |% Z" G1 V# x( g9 b5 ? A- Z3 O) o - </property>
; ^0 N; p2 b. c! `3 \& @ - <property name="myeclipse.connection.profile">mysql</property>' g' L1 ^2 h0 d% d2 p4 x
- <mapping resource="com/wireless/entity/hbm/Usertbl.hbm.xml" />8 G5 _8 n/ B) d# l- z' V
- <mapping resource="com/wireless/entity/hbm/Menutypetbl.hbm.xml" />
* X3 W5 K! m7 U6 g - <mapping resource="com/wireless/entity/hbm/Tabletbl.hbm.xml" />; M7 N, B' m5 w% i; a& @
- <mapping resource="com/wireless/entity/hbm/Menutbl.hbm.xml" />
# V E# C8 S) D - <mapping resource="com/wireless/entity/hbm/Ordertbl.hbm.xml" />
( |! H& _$ L/ K$ K- a) D - <mapping resource="com/wireless/entity/hbm/Orderdetailtbl.hbm.xml" />. v3 n) p @( z4 p) q: v
& V" y7 T! T5 [2 J7 y3 d6 [. y- </session-factory>. B7 j- K; V: U6 G
- ; T2 C& @9 s1 b/ K# e
- </hibernate-configuration>
复制代码 5:界面展示
/ U4 A7 Q' {8 a% W6 ^
0 h/ ?" ^' U& n& b+ N- d+ k& ^3 Y# e q* f! A/ g
O, ^8 }% [0 E" o) Z
0 A: y; h" }- H
4 v$ b' \1 @) o: P: f4 O5 o& {
9 G O* l5 _2 K; d
6 `. R; Z3 W ~7 V9 M
* O0 P9 v0 ^' V' n) s0 c# M4 ^
8 ?* `+ I( S7 M$ s: d1 g6 _
' Y, W: v3 S( s/ R( A* A& W
1 h9 }5 t4 `; p! j3 ]# v2 o F( A
6 `8 @, f5 o. ~4 u9 r" ^3 b2 U项目源码下载地址:javaWeb三大框架SSH + BootStrap网上订餐系统
) x9 `% C. P* ^
解压密码:
2 z+ I( A2 \ P, J6 V, R, c
$ J! A! o; B7 h1 o4 N9 O1 L" H |
-
总评分: 帮币 + 5
查看全部评分
|