不是真正的 CL 也不是 Web 编程专家,所以我可能遗漏了一些非常明显的东西:我尝试在 page-1 中设置会话值并在 page-2 中获取结果。但是,第 2 页中没有显示任何内容...
(ql:quickload "cl-who")
(ql:quickload "hunchentoot")
(defpackage :sessmin
(:use :cl :cl-who :hunchentoot))
(in-package :sessmin)
(defun start-server (port)
(start (make-instance 'easy-acceptor :port port)))
(setf (html-mode) :html5)
(define-easy-handler (page1 :uri "/page1") ()
(start-session)
(setf (session-value :sv) "testvalue")
(with-html-output-to-string
(*standard-output* nil :prologue t :indent t)
(:html :lang "en"
(:head
(:meta :charset "utf-8")
(:title "page1"))
(:body
(:p "Session Page 1")
(:p "Go to next page" (:a :href "page2" "here"))))))
(define-easy-handler (page2 :uri "/page2") ()
(with-html-output-to-string
(*standard-output* nil :prologue t :indent t)
(:html :lang "en"
(:head
(:meta :charset "utf-8")
(:title "page2"))
(:body
(:p "Session Page 2")
(:p "Session Page 2, value:" (session-value :sv))))))
(start-server 8080)
编辑:在我的第一个版本中得到“(”错误,但更正后仍然无法正常工作......