spring手动注入
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"%>
效果图如下
上一篇: 菜鸟成长自我感受与规划
下一篇: 树的插入(创建)为什么要使用指针的指针