exception:current-continuation-marks:在continuation中没有相应的提示符:#<continuation-prompt-tag:web> </continuation-prompt-tag:web>

时间:2011-09-30 09:41:16

标签: scheme racket

为什么我在这个程序中获得异常(重定向/获取)

#lang web-server
(require web-server/formlets web-server/page) (struct app (nm) #:mutable)
(define (start req) (render-main-page req))

这个函数将被大多数页面使用,并通过调用每个给定的页面生成器函数生成comlete页面xexpr,每个函数都可以嵌入它们的URL

(define (render-page embed/url a-title blocks)
     (response/xexpr `(html (head (title ,a-title) 
         (body ,@(map (lambda (block) (block embed/url)) blocks))))))

这是第一页生成器功能

(define (render-action-panel embed/url action)
  `(a ([href ,(embed/url action)]) "New"))

这是第一页

(define/page (render-main-page)
  (local [(define (new-handler req) (render-app-page req (app "new value")))
          (define (panel-block embed/url) (render-action-panel embed/url new-handler))]            
    (render-page embed/url "Title" (list panel-block))))  

这是第二页生成器功能(表示形式)

(define (add-app-formlet an-app) (formlet (#%# ,{=> input-string nm}) nm))
(define (render-app-form embed/url an-app save-handler)
  `(div (form ([action ,(embed/url save-handler)][method "POST"])
              (span ,@(formlet-display (add-app-formlet an-app) ))
              (span (input ([type "submit"][value "Save"]))))));)

第二种形式, 保存处理程序在尝试执行post-redirect-get

时抛出异常
(define/page (render-app-page an-app)
  (local [(define (save-handler req)
            (render-app-page 
             (redirect/get) 
             (set-app-nm! an-app (formlet-process (add-app-formlet an-app) req))))
          (define (form-block embed/url)
            (render-app-form embed/url an-app save-handler ))
          ]
    (render-page embed/url "Title - form: " (list form-block))))

(require web-server/servlet-env)
(serve/servlet start)

1 个答案:

答案 0 :(得分:1)

您使用的是哪个redirect/get

web-server/lang/servlet(应该与#lang web-server一起使用的)与web-server/servlet(应与#lang racket(和朋友)一起使用的那个不同)

此错误消息表示您使用的是web-server/servlet

FWIW,web-server/page不能与#lang web-server一起使用,因为它只是来自send/suspend/dispatch web-server/servlet的简单宏。