我并不是一个CL或Web编程专家,所以我可能遗漏了一些非常明显的东西:我试图在第1页中设置一个会话值,然后在第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)编辑:得到了“(”在我的第一个版本错误,仍然没有工作后,尽管更正.
发布于 2014-03-24 11:01:33
您的问题不是会话值没有设置,而是您的cl格式。
(:p "Session Page 2, value:" (session-value :sv))不会打印会话值;只忽略session-value的返回值。
;; try this:
(:p "Session Page 2, value:" (str (session-value :sv)))
;; or, if you need to html-escape the value,
(:p "Session Page 2, value:" (esc (session-value :sv)))发布于 2014-03-23 22:00:55
不是一个饥饿专家,但我想你忘了关闭:head。
https://stackoverflow.com/questions/22597363
复制相似问题