2013-07-23 30 views
2

我正在學習常見的lisp並嘗試使用hunchentoot來開發web應用程序。與hunchentoot我無法生成網頁

有了下面的代碼,我無法看到在瀏覽器上的retro-games函數定義中定義的頁面。我期望它是由這個函數生成的。

我寫的地址爲:

http://localhost:8080/retro-games.htm. 

在瀏覽器上顯示什麼是Resource /retro-games.htm not found,該消息並在默認頁面的口齒不清的標誌,我可以顯示。我可以顯示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*) 

開始的兩次加載都成功了。

我錯過了什麼?

+0

更新:我看到當我啓動與易受體類而不是上述受體類作爲實例的服務器; (啓動(使實例「易於接受:端口8080)) 它的工作原理與上面的代碼中的所有其他的事情。 – 2013-07-23 08:08:24

+0

這是與這個最近的問題有關; http://stackoverflow.com/q/17777670/1281433? –

回答

1

acceptor的請求分派方法的默認實現,生成HTTP Not Found錯誤。因此,您需要子類acceptor類,並在子類中重新定義acceptor-dispatch-request方法以使其實際發送請求。例如見documentationeasy-acceptor工作,因爲它定義acceptor-dispatch-request使用*dispatch-table*進行路由。

2

Hunchentoot的API已經改變了一下,因爲這是寫。該文章假設的acceptor的行爲現在可在easy-acceptor中找到。 Acceptor現在是一個更普遍的類,如果您非常喜歡,您可以將它用於您自己的調度機制。

所以,與其(make-instance 'hunchentoot:acceptor #|...|#),用(make-instance 'hunchentoot:easy-acceptor #|...|#),它應該工作。