Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web 以下lisp程序不支持';I don’我没有按预期工作_Web_Lisp - Fatal编程技术网

Web 以下lisp程序不支持';I don’我没有按预期工作

Web 以下lisp程序不支持';I don’我没有按预期工作,web,lisp,Web,Lisp,下面是我的lisp代码,用于完成一个简单的web服务器 ; 一些辅助函数 (require :asdf) (defun loadlib (mod) (asdf:oos 'asdf:load-op mod)) (defun reload () (load "web.lisp")) ; load 需要的库 (loadlib :html-template) (loadlib :hunchentoot) ; 设置 hunchentoot 编码 (defvar *utf-8* (flex

下面是我的lisp代码,用于完成一个简单的web服务器

; 一些辅助函数
(require :asdf)
(defun loadlib (mod)
  (asdf:oos 'asdf:load-op mod))

(defun reload ()
  (load "web.lisp"))

; load 需要的库  
(loadlib :html-template)
(loadlib :hunchentoot)

; 设置 hunchentoot 编码
(defvar *utf-8* (flex:make-external-format :utf-8 :eol-style :lf))
(setq hunchentoot:*hunchentoot-default-external-format* *utf-8*)
; 设置url handler 转发表
(push (hunchentoot:create-prefix-dispatcher "/hello" 'hello) hunchentoot:*dispatch-table*)

; 页面控制器函数
(defun hello ()
  (setf (hunchentoot:content-type*) "text/html; charset=utf-8")
  (with-output-to-string (stream)
    (html-template:fill-and-print-template
     #P"/home/chonglinsun/Learn/cl/lib/web/index.tmpl"
     (list :name "Lisp程序员")
     :stream stream)))
; 启动服务器
(defun start-web (&optional (port 4444))
  (hunchentoot:start (make-instance 'hunchentoot:acceptor :port port)))

(defun restart-web ()
  (progn
    (reload)
    (start-web)))
index.tmpl的内容如下:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Test Lisp Web</title>
  </head>
  <body>
    <h1>Lisp web开发实例</h1>
    hi, <!-- TMPL_VAR name -->
  </body>
</html>

测试LispWeb
LispWeb开发实例
你好
当我启动web时,我无法访问localhost:4444/hello,但我无法知道在哪里 问题是。我在网上搜索,有人说那是我的原因 路径但我不认为我的代码中有与之相关的东西。希望会有
有人来告诉我为什么。我使用了ubuntu 12.10。

您需要使用
简易接受器,而不是
接受器来使用
*分派表*
机制。

您是否试图从另一台机器访问web服务器?如果是这样,请检查您的防火墙设置。不,我只是使用本地计算机访问它,哪里出错了…是否存在编译错误或警告?Hunchentoot也可以写日志——你在那里找到了什么?没有编译错误或警告,脚本也没有退出。当我访问localhost:4444时,hunchentoot的日志显示:127.0.0.1-[2012-09-16 18:26:01]“GET/hello HTTP/1.1”404 184-“Mozilla/5.0(X11;Ubuntu;Linux i686;rv:15.0)Gecko/20100101 Firefox/15.0.1”