<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
p
{mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:宋体;
mso-bidi-font-family:宋体;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
1.
从页面开始,工资管理触发一个action(salary!init.action:
为多分支action
,action
名为salary,
执行的方法为init()
方法)
2.action
交给struts2
处理,读取src
目录struts.xml
文件,其中有个配置salary
的action,
如下所示:
<action name="salary"
class="salaryAction">
<result
name="list">/admin/salary_page.jsp</result>
</action>
3.
根据class="salaryAction"
交给Spring(
为什么struts
的action
会交给spring
处理呢?原因是:Struts2
提供一个jar
包
struts2-spring-plugin-2.1.2.jar
,有个struts.properties
文件,打开查找,输入auto
查找有这样一段话:
### specifies the autoWiring logic when using the
SpringObjectFactory.
### valid values are: name, type, auto, and constructor
(name is the default)
struts.objectFactory.spring.autoWire = name
。也就是有了上面那个jar
包之后,根据name
自动提交给Spring
处理)
,
读取Spring
容器的配置文件/WebRoot/WEB-INF/applicationContext.xml
文件。
<bean name="salaryAction" class="com.bu3g.ssh.web.action.SalaryAction">
<property name="empService">
<ref local="empService" />
</property>
</bean>
根据applicationContext.xml
配置文件找到com.bu3g.ssh.web.action.SalaryAction
类,其中有一个属性empService,
并提供了
setEmpService()
方法,由applicationContext.xml
文件得知该empService
对象由Spring
容器依赖注入,set
注入。
由<ref local="empService" />
这个可以知道SalaryAction
的属性empService
引用了本地的(即applicationContext.xml
文件中
配置的一个bean
)
<bean id="empService"
class="com.bu3g.ssh.service.impl.EmployeeServiceImpl">
<property name="empDAO" ref="empDAO"
/>
<property name="payDAO" ref="payDAO"
/>
</bean>
4.
取得empService
对象(
接口对接口实现类的一个引用)
后,调用它的getPager
方法。后面的就是访问DAO
了,一长串省略号代替。。。。。。。。。。。。。。