开发者

exception: current-continuation-marks: no corresponding prompt in the continuation: #<continuation-prompt-tag:web>

开发者 https://www.devze.com 2023-04-09 20:17 出处:网络
why do i get exception on (redirect/get) in this program #lang web-server (require web-server/formlets web-server/page) (struct app (nm) #:mutable)

why do i get exception on (redirect/get) in this program

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

this function is to be used by most pages and generates comlete page xexpr by calling each given piece of page generator functions, each of which may embed their urls

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

this is piece of first page generator function

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

this is first page

(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))))  

this is piece of second page generator function (represents form)

(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"]))))));)

the second form, save handler throws exception when trying do 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-se开发者_Python百科rver/servlet-env)
(serve/servlet start)


Which redirect/get are you using?

The one from web-server/lang/servlet (which should be used with #lang web-server) is different than the one from web-server/servlet (which should be used with #lang racket (and friends))

This error message means that you are using the one from web-server/servlet.

FWIW, web-server/page cannot be used with #lang web-server because it is just a simple macro over the send/suspend/dispatch from web-server/servlet.

0

精彩评论

暂无评论...
验证码 换一张
取 消