spring手动注入

2018-09-10 01:02:08来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

pojo—> Inform.hbm.xml

<hibernate-mapping>
<class name="com.ambow.pojo.Inform" table="inform" catalog="first_office" lazy="false">
<id name="id" type="integer">
<column name="id" />
<generator class="identity" />
</id>
<many-to-one name="emp" class="com.ambow.pojo.Emp" fetch="select">
<column name="empId" />
</many-to-one>
<property name="informName" type="string">
<column name="informName" />
</property>
<property name="informDesc" type="string">
<column name="informDesc" />
</property>
<property name="informDate" type="string">
<column name="informDate" />
</property>
</class>
</hibernate-mapping>

pojo->emp.hbm.xml

<hibernate-mapping>
<class name="com.ambow.pojo.Emp" table="emp" catalog="first_office" lazy="false">
<id name="id" type="integer">
<column name="id" />
<generator class="identity" />
</id>
<many-to-one name="position" class="com.ambow.pojo.Position" fetch="select">
<column name="positionId" />
</many-to-one>
<many-to-one name="dept" class="com.ambow.pojo.Dept" fetch="select">
<column name="deptId" />
</many-to-one>
<property name="empName" type="string">
<column name="empName" />
</property>
<property name="empSex" type="string">
<column name="empSex" />
</property>
<property name="empAge" type="integer">
<column name="empAge" />
</property>
<property name="empIdCard" type="string">
<column name="empIdCard" />
</property>
<property name="empPhone" type="string">
<column name="empPhone" />
</property>
<property name="empEmail" type="string">
<column name="empEmail" />
</property>
<property name="empAddress" type="string">
<column name="empAddress" />
</property>
<set name="knowledges" inverse="true">
<key>
<column name="empId" />
</key>
<one-to-many class="com.ambow.pojo.Knowledge" />
</set>
<set name="signs" inverse="true">
<key>
<column name="empId" />
</key>
<one-to-many class="com.ambow.pojo.Sign" />
</set>
<set name="newses" inverse="true">
<key>
<column name="empId" />
</key>
<one-to-many class="com.ambow.pojo.News" />
</set>
<set name="documents" inverse="true">
<key>
<column name="empId" />
</key>
<one-to-many class="com.ambow.pojo.Document" />
</set>
<set name="toleaves" inverse="true">
<key>
<column name="empId" />
</key>
<one-to-many class="com.ambow.pojo.Toleave" />
</set>
<set name="meets" inverse="true">
<key>
<column name="empId" />
</key>
<one-to-many class="com.ambow.pojo.Meet" />
</set>
<set name="informs" inverse="true">
<key>
<column name="empId" />
</key>
<one-to-many class="com.ambow.pojo.Inform" />
</set>
<set name="logininfos" inverse="true">
<key>
<column name="empId" />
</key>
<one-to-many class="com.ambow.pojo.Logininfo" />
</set>
<set name="items" inverse="true">
<key>
<column name="empId" />
</key>
<one-to-many class="com.ambow.pojo.Item" />
</set>
</class>
</hibernate-mapping>

 

dao层实现类

@Override

public List<Inform> findAllInform() {
// TODO Auto-generated method stub
Session session = sessionFactory.openSession();
Transaction tc = session.beginTransaction();
List<Inform> list=session.createQuery("from Inform").list();
tc.commit();
session.close();
return list;
}

struts2层

 

<package name="informAction" extends="struts-default">
<action name="FindAllInformAction_ssy" class="FindAllInformAction_ssy">
<result name="findallinform">/staff/publicInformationSystem/informmanager.jsp
</result>
</action>
</package>

spring层手动注入

<bean id="FindAllDaoImpl_ssy1" class="com.ambow.yuangong.dao.Impl.FindAllDaoImpl_ssy">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>

<bean id="FindAllServiceImpl_ssy1" class="com.ambow.yuangong.service.Impl.FindAllServiceImpl_ssy">
<property name="fa" ref="FindAllDaoImpl_ssy1"></property>
</bean>

<bean id="FindAllInformAction_ssy" class="com.ambow.yuangong.action.FindAllInformAction_ssy">
<property name="findinform" ref="FindAllServiceImpl_ssy1"></property>
</bean>

 

 

jsp页面显示

<body style="width:1060px;height;auto;overflow:script;marging;0 auto;">
<div style="margin-bottom: 15px;color: gray;">
<span style="font-size: 35px;">通知管理</span> <br>
<span>_______________________________________________________________________________________________________________________</span>
</div>
<center>
<form action="FindAllInformAction_ssy" method="post">
<table class="hovertable">
<tr>

<th style="text-align: center;">通知编号</th>
<th style="text-align: center;">通知名称</th>
<th style="text-align: center;">通知内容</th>
<th style="text-align: center;">指定人ID</th>
<th style="text-align: center;">发布时间</th>

</tr>
<c:forEach items="${listinform}" var="p">
<tr onmouseover="this.style.backgroundColor='#DDF2C9';"
onmouseout="this.style.backgroundColor='#d4e3e5';">
<td>${p.id}</td>
<td>${p.informName}</td>
<td>${p.informDesc}</td>
<td>${p.emp.empName}</td>
<td>${p.informDate}</td>
</tr>
</c:forEach>
</table>
</form>
<div class="demo">
<div class="container">
<div class="row pad-15">
<div class="col-md-12">
<nav class="pagination-outer" aria-label="Page navigation">
<ul class="pagination" style="color: gray;font-size: 18px">
<li>共</li>
<li>1</li>
<li>页</li>
</ul>
<ul class="pagination">
<li><a href="">首页</a></li>
</ul>
<ul class="pagination">
<li><a href="">上一页</a></li>
</ul>
<ul class="pagination">
<li><a href="">下一页</a></li>
</ul>

<!-- 尾页 -->
<ul class="pagination">
<li class="page-item"><a href="">尾页</a></li>
</ul>

</nav>
</div>
</div>
</div>
</div>
</center>
</body>

jsp注意c标签引入-><%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

我也不怎么会  大神勿喷

效果图如下

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:基本数据类型包装类

下一篇:控制反转