TA的每日心情 衰 2021-2-2 11:21
签到天数: 36 天
[LV.5]常住居民I
1.简介 后端基于spring , struts 1和hibernate ,前台用bootstrap实现。5 K r/ x: F& C% T/ m
实现的功能也比较少,基本的crud操作,文件上传,ajax异步刷新等。, S( f/ {" h" o7 _$ y
2.代码结构
% F1 `$ }2 I! E6 A
- W9 Z' b8 }1 r! n" o 3: applicationContext.xml配置文件
0 t# L$ d" F- A" g/ P <?xml version="1.0" encoding="utf-8"?>
3 t8 K' v! E) S- i6 [7 t h2 H <beans xmlns="http://www.springframework.org/schema/beans" D) z6 }. p+ h" p5 x
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 V5 w: p5 H4 `1 e9 p* G xmlns:context="http://www.springframework.org/schema/context"
0 T1 i @, B0 ~* m' m xmlns:tx="http://www.springframework.org/schema/tx"
9 _3 h) C) }0 O3 ] xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd/ |' K' w1 C+ J8 Q- M2 I
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
; K# A4 t6 U$ ~% l' O7 ?* o http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
. B8 S# J/ q1 `. O <!-- 启用注解扫描 -->
! K* i% P2 Z* e# M/ ?- o( o <context:annotation-config/>0 j. c* j. J2 X6 q8 f2 o
& s. }( K% a! r8 _/ n
<!-- 配置数据源 -->
9 u9 x* ?' n7 e2 i <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">- B$ a4 _8 R8 ~2 ^3 q9 ~
<property name="driverClassName" value="com.mysql.jdbc.Driver" />. U) }6 D$ o5 \$ U4 _' H
<property name="url" value="jdbc:mysql://localhost:3306/wireless"/>
! Q2 P: J4 h' k9 x# h- {' H7 y# h <property name="username" value="root"/>
$ l5 y2 V4 h$ \ <property name="password" value="110511"/>
% L0 \3 f" a( M </bean>/ h, ]( T$ f9 n& `5 a( A
<!-- 配置会话工厂 -->
0 |! _" O' ?: g- J <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">) I' b' X R, o( l; b" Z
<!-- 设置数据源 -->
7 d, K- m. b3 q <property name="dataSource" ref="dataSource" />
& q; Z7 [2 y, |& g <!-- 配置映射文件 --># `% t* J0 d4 N5 z
<property name="mappingResources">
2 D5 z8 s8 [: V: v) y9 A <list>
& p, h; D& q9 ?( \8 b <value>com/wireless/entity/hbm/Usertbl.hbm.xml</value>
' ^4 P3 _, R8 n <value>com/wireless/entity/hbm/Menutypetbl.hbm.xml</value>
6 q, Q. z! ^: I. {: v3 L1 L <value>com/wireless/entity/hbm/Tabletbl.hbm.xml</value>. V; K; D# ~# ?$ U2 g; R: x
<value>com/wireless/entity/hbm/Menutbl.hbm.xml</value>
1 v' ]( i. y+ X! s# u$ D <value>com/wireless/entity/hbm/Ordertbl.hbm.xml</value>
5 Y& N* ^+ A9 w, S <value>com/wireless/entity/hbm/Orderdetailtbl.hbm.xml</value>- _7 G$ U2 @8 D: d9 N
</list>! t$ l4 s$ c7 t' Y" P' H
</property>
6 Q; R& ?4 L8 D4 X3 E <property name="hibernateProperties">
" F8 o% b2 f7 l& \# G0 I- V" ^ <props>' P; x5 D4 C( ]) H- s& ?" Y
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- h! k+ _. o/ z/ ?: O3 I3 C <prop key="hibernate.hbm2ddl.auto">update</prop>
* V) G: F4 [( `1 j- m <prop key="hibernate.show_sql">true</prop>& F& k6 [ a a* R8 M
<prop key="hibernate.cache.use_second_level_cache">true</prop>
6 g4 m1 F( \7 d, O, A <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
6 X5 a; j) j4 |7 ? <prop key=" hibernate.generate_statistics">true</prop>
- O) M9 \' p$ o5 R7 o# ` C " `+ H1 _5 Z7 H
</props>5 F# L) {/ q! y: X! w
</property>
2 W# u; ?: p$ K0 R1 ]( F; s </bean>
' [7 _4 V$ m& A, ]3 Z 1 e, `' \. Z- }% v; v! b- n5 p
<!-- 配置Service -->
. W5 D% K1 h. l % |! G' E; T7 T% I8 P
<!-- 配置Service -->
4 l$ J( a7 S- i I <bean id="userService" class="com.wireless.web.service.impl.UserServiceImpl" />
h4 ?( A4 U3 L, P <bean id="tableService" class="com.wireless.web.service.impl.TableServiceImpl" />
& A9 R5 ^$ ^0 }$ I# N0 } <bean id="menuService" class="com.wireless.web.service.impl.MenuServiceImpl" />4 H3 H) H( z. h! w2 @! r" d
<bean id="orderService" class="com.wireless.web.service.impl.OrderServiceImpl" />. L8 L" X' W) K
+ `1 M" [* E* ]5 ^: H! O% s
<!-- 配置action ,prototype为原型,每次生成新的action 解决并发问题-->* W3 @2 P0 s. l. e) L E3 _
<bean name="/login" class="com.wireless.web.action.LoginAction" >
* S7 d1 U! w, h' [" @ <property name="userService" ref="userService"></property>8 \ V8 j: c: P- m( {% p, j
</bean>
2 a3 }6 C3 \4 s: N R0 M0 Y <bean name="/home" class="com.wireless.web.action.HomeAction" >1 t: @! o( ?5 t8 J3 T
<property name="userService" ref="userService"></property>
, |6 j" q4 ^) O: \2 {9 T </bean>$ n( ~9 K, } O3 q& G' d+ P
<bean name="/table" class="com.wireless.web.action.TableAction" >
; N6 e+ ^0 e+ J/ {4 e <property name="tableService" ref="tableService"></property>
/ r2 y! _- _* D! _6 [ </bean>4 K% S# n6 t. W6 c+ U
<bean name="/menu" class="com.wireless.web.action.MenuAction" ># k u/ a- A' H& X; ^
<property name="menuService" ref="menuService"></property>, E6 b* [- T9 i. |& H
</bean>7 J( ]' f2 @, m; t1 W
<bean name="/order" class="com.wireless.web.action.OrderAction" >
4 ~0 N+ ]- B( C! T+ ~ n3 N. ? n <property name="orderService" ref="orderService"></property>
( G k2 h6 P! V& |& d$ { P </bean>3 p |! D) d, |: M' b/ y4 h
8 O7 |1 U4 W4 T( h _2 u4 R <!-- 配置事务管理器,统一管理sessionFactory的事务 -->
. V3 V9 U) d# I" v5 g <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">& a7 j4 f1 _ n0 a" J( F
<property name="sessionFactory" ref="sessionFactory"/>- {; h' j) M5 d* O
</bean>3 J& X: P3 e& O6 e" x/ n7 V
<!-- 启用事务注解 -->
6 W! w$ u6 y- R: B0 L <tx:annotation-driven transaction-manager="txManager"/>
% {1 W5 [! Z' @2 C" T) ]9 C. F! N
, i/ K# C; Y, Z; S0 h* O3 u8 y6 G </beans>7 F9 {8 ^; h/ ^! r( i, q3 K6 v6 N. r
复制代码 4:hibernate.cfg.xml配置文件 8 M+ @" A, N( g, D; }
<?xml version='1.0' encoding='UTF-8'?>9 O" r& {: P, A
<!DOCTYPE hibernate-configuration PUBLIC
9 d5 z! P" d* H- v1 q7 L "-//Hibernate/Hibernate Configuration DTD 3.0//EN". |( F' w* m W7 A
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">( Y$ j4 _: R& B/ T8 d2 w9 P- n- `& J
/ \3 d8 L7 j9 ?% t6 Y <!-- Generated by MyEclipse Hibernate Tools. -->
! l* {2 Y/ Y4 z8 k8 Y0 V3 o <hibernate-configuration>' n9 |. s" i" p& A
" l* f4 e3 i" D; S
<session-factory>
% L# y* k, C. ^, o" E8 ~! l <property name="dialect">1 c/ P% s# Z5 ?( g4 ?
org.hibernate.dialect.MySQLDialect1 a' |) U' u0 V [
</property>
: H7 u% K3 k6 d0 o2 V <property name="connection.url">
, ^: K2 x- z6 x8 U& { jdbc:mysql://localhost:3306/struts
( h" m, s& J- ?2 S* ]( S </property>
; I! G' t6 p" r0 K! S, k <property name="connection.username">root</property>
4 z% G7 q9 V( }6 g; ^9 ? <property name="connection.password">110511</property>
6 b9 H) L& t& d9 Q <property name="connection.driver_class">
6 y* L' u( S, y9 H& U9 j m com.mysql.jdbc.Driver: _# w0 r9 g* [: H7 M4 r# N% D/ {/ ?
</property>+ v! |) H Z8 ~3 N; K
<property name="myeclipse.connection.profile">mysql</property>. ?# A7 v y. B" e
<mapping resource="com/wireless/entity/hbm/Usertbl.hbm.xml" />
; k/ j, f3 p2 L5 r7 ?% q2 H <mapping resource="com/wireless/entity/hbm/Menutypetbl.hbm.xml" />" c$ l" ]/ H5 x! o/ N% d
<mapping resource="com/wireless/entity/hbm/Tabletbl.hbm.xml" />1 w K. f( X( D: t1 A! J( s
<mapping resource="com/wireless/entity/hbm/Menutbl.hbm.xml" />
4 x( I# g/ }$ r, i& P: k <mapping resource="com/wireless/entity/hbm/Ordertbl.hbm.xml" />2 r& Z" `* ^7 K! z5 V3 l/ |6 K
<mapping resource="com/wireless/entity/hbm/Orderdetailtbl.hbm.xml" />- ^" {7 \9 n! P! h. V
0 e4 n" ~* c% \. X4 w) w% O/ F" C
</session-factory>+ N2 x/ z9 W( c; T! T
* W2 B9 p3 R5 R8 c# s' w$ q
</hibernate-configuration> 复制代码 5:界面展示
" @4 k; O' _* g" h/ l
1 q) z9 m& \: O6 \# Q P. D
. Z' u- `. Z! l% D1 S- x' @
+ w8 k" v. l) I) H
0 Y+ U* ] y, j
( ^/ ]* I3 f" t" V/ g( F
c# j' C" E, Y/ L, ~
2 r, \+ F8 q7 S& J4 O, u+ i# U- @
0 W$ Y, ?. H" E: k+ `" i
& x' Y/ K: x' `0 {6 k
8 f6 W3 w+ S$ W5 Y0 y
& r, L* n6 [% |+ c- W
, I# f. M9 m1 B6 [ s, K' d( g
1 a& J1 m; b6 \9 ~1 _ 项目源码 下载地址:javaWeb三大框架SSH + BootStrap网上订餐系统 J* j7 T0 q2 _+ G, J6 w
解压密码: 1 a- b" o: t7 V9 S8 t$ |. U8 P
; U% A( p- d g% ^
科帮网 1、本主题所有言论和图片纯属会员个人意见,与本社区立场无关2、本站所有主题由该帖子作者发表,该帖子作者与科帮网 享有帖子相关版权3、其他单位或个人使用、转载或引用本文时必须同时征得该帖子作者和科帮网 的同意4、帖子作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任5、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责6、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意7、科帮网 管理员和版主有权不事先通知发贴者而删除本文
JAVA爱好者①群:
JAVA爱好者②群:
JAVA爱好者③ :
总评分: 帮币 + 5
查看全部评分