页面传递参数:
/**
* 邮箱发送事件
*/
sendEmail:function () {
<!--自己添加-->
var grid= $("#grid").data("kendoGrid");
var checked = grid.selectedDataItems();
var data = JSON.stringify(checked);
console.log(data)
$.ajax({
//url: '${base.contextPath}/ora/20796/hap/demo/send/email',
url: '${base.contextPath}/wht/ora/20796/student/send/email',
type: 'POST',
dataType: "json",
data:data,
contentType: "application/json",
success: function (result) {
if (result.success) {
kendo.ui.showInfoDialog({
title: $l('hap.tip.info'),
message: $l("hap.success")
});
viewModel.query();
} else {
kendo.ui.showErrorDialog({
title: $l('hap.error'),
message: result.message
});
}
}
});
},
后台接收参数:
- 接口:
package wht.ora20796.service;
import com.hand.hap.core.IRequest;
import com.hand.hap.core.ProxySelf;
import com.hand.hap.system.dto.ResponseData;
import com.hand.hap.system.service.IBaseService;
import wht.ora20796.dto.Ora20796Student;
import java.io.InputStream;
import java.util.List;
public interface IOra20796StudentService extends IBaseService<Ora20796Student>, ProxySelf<IOra20796StudentService>{
/**
* 邮箱发送
*/
ResponseData sendEmail(IRequest iRequest, List<Ora20796Student> dto)throws Exception;
ResponseData importExcel(InputStream is, String fileName) throws Exception;
}
- 实现类
/**
* 邮箱发送
*
* @param iRequest
* @return
* @throws Exception
*/
@Override
public ResponseData sendEmail(IRequest request,List<Ora20796Student> dto) throws Exception {
ResponseData responseData = new ResponseData();
HashMap<String, Object> templateData = new HashMap<String, Object>();
/*templateData.put("StudentName", "This is a test email from Demo page");
templateData.put("UserName", request.getUserName());
//收件人,可以有多人
ArrayList<MessageReceiver> receivers = new ArrayList<>();
MessageReceiver messageReceiver = new MessageReceiver();
messageReceiver.setMessageAddress("shizhou.cui@hand-china.com");
//messageReceiver.setMessageAddress("1101133246@qq.com");
messageReceiver.setMessageType(ReceiverTypeEnum.NORMAL.getCode());
receivers.add(messageReceiver);
//messageService.sendMessage(request, "ACT_EMAIL_NOTIFIER", templateData, receivers, (List<Long>) null);
//messageService.sendMessage(request, "ORA_20796_DEMO3", templateData, receivers, (List<Long>) null);
messageService.sendMessage(request, "ORA_20796_HOMEWORK", templateData, receivers, (List<Long>) null);
*/
for(Ora20796Student student:dto){
ArrayList<MessageReceiver> receivers = new ArrayList<>();
templateData.put("StudentName",student.getStudentName());
templateData.put("UserName",request.getUserName());
MessageReceiver messageReceiver = new MessageReceiver();
messageReceiver.setMessageAddress(student.getEmail());
messageReceiver.setMessageType(ReceiverTypeEnum.NORMAL.getCode());
receivers.add(messageReceiver);
messageService.sendMessage(request,"ORA_20796_HOMEWORK",templateData,receivers,(List<Long>) null );
}
return responseData;
}