gpt4 book ai didi

grails - gsp邮件插件自动发送

转载 作者:行者123 更新时间:2023-12-02 15:33:56 25 4
gpt4 key购买 nike

导航到页面时,为什么会自动调用send()函数?

我希望能够查看gsp页面,填写一些文本字段,然后使用“发送”操作调用提交

这是我的gsp文件

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<meta name="layout" content="main"/>
<title>Contact Form</title>
</head>
<body>
<g:form name="contactForm" action = "send">
<g:render template = "contactFormFields"/>
<g:actionSubmit value = "submit" action = "send"/>
</g:form>
</body>
</html>

这是contactFormFields模板
<g:select name = 'subject' from = '${EmailService.options}' noSelection='Topic'/>

Contact Name: <g:textField name = "contact"/>
Contact Number: <g:textField name = "phone"/>
Contact Email: <g:textField name = "email"/>
Aditional Information:
<g:textArea name = "information" rows="5" cols="40"/>

EmailServiceController
class EmailServiceController {

def defaultAction = "contactService"

def send() {
sendMail(){
to "mygroovytest@gmail.com"
from params.email
subject params.subject
body params.information
}
}
}

域类
class EmailService {

static constraints = {
def options = new ArrayList()
options.push("Qestions about service")
options.push("Feedback on performed service")
options.push("Other")
options.push("Why am I doing this")
}
}

调用服务的gsp
<div class="banner">
<h1>My HVAC company</h1>
<a href = "javascript: contactPop()"> Contact me today!</a>
<a href = "services">Services</a>
<a href = "emailService">Have Me Contact You!</a>
</div>

最佳答案

您的contactService中没有EmailServiceController Action ,因此当您链接到没有 Action 名称的 Controller 时,它可能会将send()视为默认 Action 。尝试添加一个空的contactService操作

def contactService() { }

关于grails - gsp邮件插件自动发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14846325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com