如何将 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>
"""

有帮助吗?

解决方案

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

我个人并没有这样做来合并 groovlet,但这是修改已部署 Grails 的记录方法 web.xml

scroll top