使用DWR库以Spring形式提交

时间:2017-11-14 10:09:59

标签: ajax spring dwr spring-form

在J2EE项目中,我们使用的是DWR库。熟悉简单的ajax调用和小DWR,我无法确定在我们的一个弹簧形式中单击提交按钮时后端使用了哪个服务调用。

KRIDeclaration.jsp文件: Spring Form标签:

<form:form commandName="KRIDeclarationCommand" name="krideclaration" method="post"  enctype="multipart/form-data">
........
Submit button: <td height="20" colspan="4" align="right" class="dvtCellLabel">
            <div align="center"><span style="padding-top: 5px;"> <input
                class="btnstyle" type="button" name="btnSendForApproval"
                 value="Submit" onClick="declareIncident();" />

KRIDecleration.js

declareIncident()
{
  Basic front end Validation
Backend Validation using DWR generated js file with a callback
}
callbackmethod(Result)
{
if (success)
document.krideclaration.submit();
else 
//code for displaying errors.

}

DWR-context.xml中:

dwr:annotation-scan base-package="com.abc.riskdashboard.common" scanDataTransferObject="true" scanRemoteProxy="true" />

 <!-- DWR will map util.js and engine.js files to the dwrController.
  You can then include this files as external Javascript references from your JSP -->

 <dwr:url-mapping />

 <!-- Defines the dwrController. During production, set the debug property to false -->

 <dwr:controller id="dwrController" debug="true" />

 <!-- This is required if you want to configure any beans not managed by
  Spring. Leaving it enabled doesn't do any negative effects.
  -->

   <dwr:configuration>
   <dwr:convert type="bean" class="com.abc.riskdashboard.common.dto.RiskAreaMasterDTO" />
   <dwr:convert type="bean" class="com.abc.riskdashboard.common.dto.RiskIndicatorDTO" />
   <dwr:convert type="bean" class="com.abc.riskdashboard.common.dto.RiskDeclarationDTO" />
   <dwr:convert type="bean" class="com.abc.riskdashboard.common.dto.UserMasterDTO" />
   <dwr:convert type="bean" class="com.abc.riskdashboard.common.dto.RoleMasterDTO" />

成功时需要找出KRIDecleration.js中调用的document.krideclaration.submit()。弹簧形式没有提交功能或动作属性

0 个答案:

没有答案