我正在学习普通的lisp,并尝试使用hunchentoot来开发web应用程序。
使用下面的代码,我无法在浏览器上看到在复古游戏函数定义中定义的页面。我希望它由这个函数生成。
我把地址写成:
http://localhost:8080/retro-games.htm.浏览器上显示的是我可以显示的Resource /retro-games.htm not found、消息和默认页面上的lisp徽标。我可以显示hunchentoot的默认页面。
(ql:quickload "hunchentoot")
(ql:quickload "cl-who")
(defpackage :retro-games
(:use :cl :cl-who :hunchentoot))
(in-package :retro-games);i evaluate this from toplevel otherwise it does not change to this package.
(start (make-instance 'hunchentoot:acceptor :port 8080))
(defun retro-games ()
(with-html-output (*standard-output* nil :prologue t)
(:html (:body "Not much there"))
(values)))
(push (create-prefix-dispatcher "/retro-games.htm" 'retro-games) *dispatch-table*)开始时的两次加载都是成功的。
我遗漏了什么?
发布于 2013-07-23 20:36:28
自那以后,Hunchentoot的应用程序接口发生了一些变化。那篇文章假设的acceptor的行为现在可以在easy-acceptor中找到。Acceptor现在是一个更通用的类,如果你有兴趣的话,你可以使用它来实现你自己的分派机制。
因此,使用(make-instance 'hunchentoot:easy-acceptor #|...|#)而不是(make-instance 'hunchentoot:acceptor #|...|#),它应该可以工作。
发布于 2013-07-23 20:28:58
acceptor的请求分派方法的默认实现会生成HTTP Not Found错误。因此,您需要子类化acceptor类,并在子类中重新定义acceptor-dispatch-request方法,以使其真正分派请求。例如,参见documentation。easy-acceptor之所以有效,是因为它定义了acceptor-dispatch-request以使用*dispatch-table*进行路由。
https://stackoverflow.com/questions/17808613
复制相似问题