ページに移動すると、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>