在尝试在球拍中使用格式时,我不断遇到错误,但我遇到了麻烦。它说:
; lifted/5.1: undefined;
; cannot reference an identifier before its definition
; in module: top-level
; internal name: lifted/5.1
我的代码中没有任何东西被命名为“ lifted”或“ 5.1”或两者的任何组合。我认为这是我所要面对的表单黑匣子中的东西,但我不知道是什么。
; set up
(require web-server/servlet web-server/servlet-env)
(require web-server/formlets)
; body of program
(define simpleformlet
(formlet
(#%#
"Name: " ,{input-string . => . name}
"Number: " ,{input-int . => . number})
(name number)))
(define (start request)
(showpage request))
(define (showpage request)
(define (responsegen embed/url)
(response/xexpr
`(html
(head (title "App3"))
(body (h1 "Let's try this...")
(form
([action ,(embed/url actionhandler)]
[method "POST"])
,@(formlet-display simpleformlet)
(input ([type "submit"])))))))
(define (actionhandler request)
(define-values (name number)
(formlet-process simpleformlet request))
(response/xexpr
`(html
(head (title "Alright!"))
(body (h2 "name")
(p ,name)
(h2 "number")
(p ,number)))))
(send/suspend/dispatch responsegen))
; run it!
(serve/servlet start
#:servlet-regexp #rx""
#:servlet-path "/form")
答案 0 :(得分:0)
我添加了一行
#lang racket
位于程序顶部。在DrRacket左下角使用“从源代码确定语言”。并运行您的程序。在出现明显错误之前,浏览器窗口打开,我能够输入名称和数字。
我正在使用Racket 6.12版,因此,如果您使用的是Racket的旧版本,请升级并重试。