spring 与 struts 书写过程中的容易疏忽的地方
(参数的注入,如果搞错会获取不到应该得到的参数值及应有的响应值)
struts中:
public String queryA() throws Throwable {
//以下代码用异常块包裹
res = new HashMap<String, Object>(); //res 为全局参数,businessModel, borrowerId都有getset方法,手动注入;
loanQualificationService.queryifUploadProgram(businessModel, borrowerId);
return success;
}
对应的action的配置:
<action name="queryA" class="com.pear.statistic.action.LoanAction" method="queryA">
<result type="json" >
<param name="root">res</param>
</result>
</action>
spring中:
public String queryA(String businessModel,int borrowerId) throws Throwable {
//以下代码用异常块包裹
res = new HashMap<String, Object>(); //全局参数,有getset方法,businessModel, borrowerId自动注入,但需要与页面传来的参数名称一致
loanQualificationService.queryifUploadProgram(businessModel, borrowerId);
}