Grails Send HTML 方法错误的邮件签名

Grails Send HTML Mail signature of method error

我正在尝试弄清楚如何使用邮件发送功能发送 html 邮件。我被卡住了,并收到“没有方法签名:适用于参数类型:(null) 值:[null]”这是我试图传递给电子邮件的请求 ID 变量。

下面是我的工作

import groovy.util.logging.Slf4j
import org.camunda.bpm.client.ExternalTaskClient
import org.camunda.bpm.client.task.ExternalTask
import org.camunda.bpm.engine.ProcessEngines
import org.camunda.bpm.engine.ProcessEngine
import grails.core.GrailsApplication
import edu.andrews.bpm.changeofprogram.EmailReceivedRequestExternalTaskService
import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider
//import edu.andrews.bpm.changeofprogram.StudentApprovalRequestController
import org.springframework.beans.factory.annotation.Value
@Slf4j



class EmailReceivedRequestExternalTaskJob {
    EmailReceivedRequestExternalTaskService emailReceivedRequestExternalTaskService
//    StudentApprovalRequestController studentApprovalRequestController

    @Value('${camunda.bpm.rest.endpoint}')
    String bpmRESTUrl

    static triggers = {
        //                                                                              s m   h D M W Y
        cron name:   'EmailReceivedRequestExternalTask',   startDelay: 10000, cronExpression: '0 */5 * * * ?'
    }

    def execute() {
        // execute job by Polling Camunda BPM for tasks on the topic
        // specified in the Camunda Modeler implementation semantics
        log.info("EmailReceivedRequestExternalTaskService polling of BPM endpoint ${bpmRESTUrl} starting...")

        ExternalTaskClient client = ExternalTaskClient.create()
                .baseUrl(bpmRESTUrl)
                .maxTasks(5)
        // .addInterceptor(new BasicAuthProvider(username, password))
                .build()
        client.subscribe("ProgramChangeReceivedEmail") // topic from Camunda Modeler
                .lockDuration(10000L)
                .handler( { externalTask, externalTaskService ->
                    log.info("Executing external task handler...")
                    Map<String,Object> procVars = externalTask.getAllVariables()
                    Map<String,Object> stuApproveVars = externalTask.getAllVariables()
                    String requestId = procVars.requestId
//                   def String idn  = procVars.idn
                    String email = stuApproveVars.email
                    emailReceivedRequestExternalTaskService.studentApprovalRequest(email)
                    emailReceivedRequestExternalTaskService.studentApprovalRequest(idn)
                    log.info("\texternalTaskVars: ${procVars}")
                    externalTaskService.complete(externalTask)

                }).open()

        client.stop()

        log.info("EmailReceivedRequestExternalTaskService...")
        //log.info(idn)
    }
}

这是服务调用

import grails.gorm.services.Service
import grails.gorm.transactions.Transactional

@Transactional
class EmailReceivedRequestExternalTaskService {

//   def ApplyAcknowledgment(String email, String studentName) {
    def ChangeAcknowledgment(String email, String requestId) {
        sendMail {
            async true
            from "donnotreply@andrews.edu"
            to email
            subject "Change of Program"
//            text "Thank you for submitting your change of program request. You will receive an email when it has been approved or denied."
           html view: "/studentApprovalRequest/AcknowledgementEmail", model: [param1: requestId]
//            html view: "/freeclass/FreeClassApplyAcknowledgment"

        }

    }
}

这是 gsp html 信息

<html>
 <head>
 </head>
 <body>
                    <p>Thank you for submitting your change of program request. You will receive an email when it has been approved or denied.</p>
                    <p>record: ${requestId}</p>
                    "<p>Thank you.</p>"
</body>
</html>

其中一个问题是您的 GSP 似乎需要一个名为 requestId 的模型变量,但 EmailReceivedRequestExternalTaskJob 正在创建一个名为 param1:

的模型变量
html view: "/studentApprovalRequest/AcknowledgementEmail", model: [param1: requestId]

你可以把它改成这样:

html view: "/studentApprovalRequest/AcknowledgementEmail", model: [requestId: requestId]

是我对事情的误解。在 .gsp 页面中,我应该将我的变量引用为 ${param1} 而不是 ${requestId}