1.Spring配置文件 applicationContext.xml
<property name="mappingResources">
<list>
<value>com/liulianggu/model/UserInfo.hbm.xml</value>
<value>com/liulianggu/model/MobileDataInfo.hbm.xml</value>
<value>com/liulianggu/model/MonthDataInfo.hbm.xml</value>
<value>com/liulianggu/model/FriendshipsInfo.hbm.xml</value>
<value>com/liulianggu/model/TransactionInfo.hbm.xml</value>
</list>
</property>
这是你所写的数据库表的hibernate配置文件
其中的每个<value>对应一个数据库表以及配置文件
2.Spring中负责注入的扫描器scan
<context:component-scan base-package="com.liulianggu">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
在你需要注入的类之前加上@component标识,例:
@Component
public class FriendshipsInfoDaoImpl implements FriendshipsInfoDao{}
其中dao的具体实现和service的具体实现需要注入,action不需要注入
在你需要注入的对象之前加上@Resource标识,例:
@Resource
private SessionFactory sessionFactory;
@Resource
private SelectFriendshipsInfoService selectFriendshipsInfoService;
其中service、dao、
sessionFactory需要注入,并且在每个需要注入的对象之前紧贴@Resource标识!!!
3.Struts配置文件 Struts.xml
<package name="com.liulianggu.action" extends="struts-default" namespace="/"></package>
<package name="liulianggu" namespace="/" extends="<span style="color:#cc6600;">json-default</span>">
这是两种关于package的定义
第一种主要用于jsp的跳转
<action name="uploadfile" class="com.liulianggu.action.ForJump">
<result name="success"> /imageFile/uploadfile.jsp </result>
</action>
name="action名字"
class="调用的类名"(具体路径)
result表示返回值及对应的反应/跳转
第二种主要用于json格式数据的传输,需要导入相关的json包
<action name="NewUserInfo" class="com.liulianggu.action.NewUserInfoAction" method="execute">
<result name="success" type="<span style="color:#ff9900;">json</span>">
</result>
<result name="error" type="json">
</result>
</action>
method="调用的方法名"
result的type="json"
4.hibernate配置文件jdbc.oracle.properties
hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc\:mysql\://127.0.0.1\:3306/liulianggu
hibernate.connection.username root
hibernate.connection.password xxxx
指明数据库的driver、url、username、password