J2EE环境搭建感悟

1、总体上先分层

a、src(默认的)b、config(配置文件)c、test(测试用)d、WebRoot下的css、images、js、pages、upload等。

2、加入框架

a、先加入spring支持。b、随后hibernate及struts支持

其中a中,spring框架加入后,首先,加入show_sql,format_sql。如

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>

<prop key="hibernate.show_sql">
true
</prop>

<prop key="hibernate.format_sql">
true
</prop>

</props>
</property>

其次、加入hibernate模板类。

<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

3、加入公共页面如error.jsp等等。

4、为src分层如:dao,service,action,utils等级目录。又可以再分为前后端。

5、为config(配置文件)分层,包括hibernate,spring,struts等目录,在spring目录下加入例如applicationContext-transaction.xml等文件;在struts配置下加入struts.xml等文件;在hibernate文件下加入生成pojo的.hbm.xml类型文件;加入log4j。

6、web.xml中加入监听

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/classes/spring/applicationContext-*.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

7、导入数据库连接jar包

8、重启服务器,测试,如果看到控制台spring,hibernate,struts信息正常,没报错,证明环境搭建成功!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值