Grails应用程序中的Groovlet

3 grails groovy

如何将Groovlet放入Grails应用程序?比如说,在web-app/groovlet.groovy中

import java.util.Date

if (session == null) {
  session = request.getSession(true);
}

if (session.counter == null) {
  session.counter = 1
}

println """
<html>
    <head>
        <title>Groovy Servlet</title>
    </head>
    <body>
Hello, ${request.remoteHost}: Counter: ${session.counter}! Date: ${new Date()}
<br>
"""

Ken*_*tle 6

  1. grails install-templates
  2. 编辑src/templates/web/web.xml以包含您的groovlet
  3. grails war
  4. 部署

我个人并没有这样做来整合一个groovlet,但这是修改部署的Grails的文档化方法 web.xml